Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06b891e

Browse files
committed
Removing repetitive code and using a Preprocessor Macro for BOOST_NETWORK_DEFINE_TAG.
1 parenta4c4e02 commit06b891e

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
namespaceboost {namespacenetwork {namespacetags {
1717

18-
structasync {int unused;};
19-
structhttp {int unused;};
20-
structtcp {int unused;};
21-
structudp {int unused;};
22-
structsync {int unused;};
23-
structkeepalive {int unused;};
24-
structsimple {int unused;};
25-
structdefault_string {int unused;};
26-
structdefault_wstring {int unused;};
18+
structasync {};
19+
structhttp {};
20+
structtcp {};
21+
structudp {};
22+
structsync {};
23+
structkeepalive {};
24+
structsimple {};
25+
structdefault_string {};
26+
structdefault_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<classTag>
3939
structcomponents;
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-
structcomponents<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-
structcomponents<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-
structcomponents<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-
structcomponents<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-
structcomponents<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-
structcomponents<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-
structcomponents<http_async_8bit_tcp_resolve> {
109-
typedef http_async_8bit_tcp_resolve_tags type;
110-
};
41+
// Tag Definition Macro Helper
42+
#defineBOOST_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<>structcomponents<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)

[8]ページ先頭

©2009-2025 Movatter.jp