Skip to content

Commit 06b891e

Browse files
committed
Removing repetitive code and using a Preprocessor Macro for BOOST_NETWORK_DEFINE_TAG.
1 parent a4c4e02 commit 06b891e

File tree

1 file changed

+26
-79
lines changed

1 file changed

+26
-79
lines changed

boost/network/tags.hpp

Lines changed: 26 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
namespace boost { namespace network { namespace tags {
1717

18-
struct async { int unused; };
19-
struct http { int unused; };
20-
struct tcp { int unused; };
21-
struct udp { int unused; };
22-
struct sync { int unused; };
23-
struct keepalive { int unused; };
24-
struct simple { int unused; };
25-
struct default_string { int unused; };
26-
struct default_wstring { int unused; };
18+
struct async {};
19+
struct http {};
20+
struct tcp {};
21+
struct udp {};
22+
struct sync {};
23+
struct keepalive {};
24+
struct simple {};
25+
struct default_string {};
26+
struct default_wstring {};
2727

2828
// FIXME move out these HTTP-only tags into different files
2929

@@ -38,79 +38,26 @@ namespace boost { namespace network { namespace tags {
3838
template <class Tag>
3939
struct components;
4040

41-
// FIXME make this a preprocessor macro!
42-
typedef mpl::inherit_linearly<
43-
http_default_8bit_tcp_resolve_tags,
44-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
45-
>::type http_default_8bit_tcp_resolve;
46-
47-
template <>
48-
struct components<http_default_8bit_tcp_resolve> {
49-
typedef http_default_8bit_tcp_resolve_tags type;
50-
};
51-
52-
typedef mpl::inherit_linearly<
53-
http_default_8bit_udp_resolve_tags,
54-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
55-
>::type http_default_8bit_udp_resolve;
56-
57-
template <>
58-
struct components<http_default_8bit_udp_resolve> {
59-
typedef http_default_8bit_udp_resolve_tags type;
60-
};
61-
62-
typedef mpl::inherit_linearly<
63-
http_keepalive_8bit_tcp_resolve_tags,
64-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
65-
>::type http_keepalive_8bit_tcp_resolve;
66-
67-
template <>
68-
struct components<http_keepalive_8bit_tcp_resolve> {
69-
typedef http_keepalive_8bit_tcp_resolve_tags type;
70-
};
71-
72-
typedef mpl::inherit_linearly<
73-
http_keepalive_8bit_udp_resolve_tags,
74-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
75-
>::type http_keepalive_8bit_udp_resolve;
76-
77-
template <>
78-
struct components<http_keepalive_8bit_udp_resolve> {
79-
typedef http_keepalive_8bit_udp_resolve_tags type;
80-
};
81-
82-
typedef mpl::inherit_linearly<
83-
http_server_tags,
84-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
85-
>::type http_server;
86-
87-
template <>
88-
struct components<http_server> {
89-
typedef http_server_tags type;
90-
};
91-
92-
typedef mpl::inherit_linearly<
93-
http_async_8bit_udp_resolve_tags,
94-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
95-
>::type http_async_8bit_udp_resolve;
96-
97-
template <>
98-
struct components<http_async_8bit_udp_resolve> {
99-
typedef http_async_8bit_udp_resolve_tags type;
100-
};
101-
102-
typedef mpl::inherit_linearly<
103-
http_async_8bit_tcp_resolve_tags,
104-
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>
105-
>::type http_async_8bit_tcp_resolve;
106-
107-
template <>
108-
struct components<http_async_8bit_tcp_resolve> {
109-
typedef http_async_8bit_tcp_resolve_tags type;
110-
};
41+
// Tag Definition Macro Helper
42+
#define BOOST_NETWORK_DEFINE_TAG(name) \
43+
typedef mpl::inherit_linearly< \
44+
name##_tags, \
45+
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2> \
46+
>::type name; \
47+
template <> struct components<name> { typedef name##_tags type; }; \
48+
49+
BOOST_NETWORK_DEFINE_TAG(http_default_8bit_tcp_resolve);
50+
BOOST_NETWORK_DEFINE_TAG(http_default_8bit_udp_resolve);
51+
BOOST_NETWORK_DEFINE_TAG(http_keepalive_8bit_tcp_resolve);
52+
BOOST_NETWORK_DEFINE_TAG(http_keepalive_8bit_udp_resolve);
53+
BOOST_NETWORK_DEFINE_TAG(http_async_8bit_udp_resolve);
54+
BOOST_NETWORK_DEFINE_TAG(http_async_8bit_tcp_resolve);
55+
BOOST_NETWORK_DEFINE_TAG(http_server);
11156

11257
typedef default_string default_;
11358

59+
#undef BOOST_NETWORK_DEFINE_TAG
60+
11461
} // namespace tags
11562

11663
} // namespace network

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy