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

Commitf347a5f

Browse files
committed
Compile-time Reduction Techniques
This commit hilights the effect of hiding the MPL details into thebase class instead of a typedef. Instead of just a typedef, useBoost.MPL metafunctions as base classes. i.e. instead of: typedef typename mpl::inherit_linearly<...>::type tag_name;Do this instead: struct tag_name : mpl::inherit_linearly<...>::type {};This then makes the tag back into an opaque type that thecompiler doesn't have to keep instantiating over and over againin the cases where the tag is used.Also because all the metafunctions deal with opaque tags and whetherthey inherit from specific root/base tags, then the compile times aregreatly reduced. You can call this type erasure at compile-time usingOOP facilities.
1 parent3efd6c0 commitf347a5f

File tree

9 files changed

+16
-31
lines changed

9 files changed

+16
-31
lines changed

‎boost/network/protocol/http/client.hpp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include<boost/network/protocol/http/client/facade.hpp>
2727
#include<boost/network/protocol/http/client/pimpl.hpp>
2828

29-
#include<boost/network/support/sync_only.hpp>
30-
31-
3229
namespaceboost {namespacenetwork {namespacehttp {
3330

3431
template<classTag,unsigned version_major,unsigned version_minor>
@@ -39,7 +36,7 @@ namespace boost { namespace network { namespace http {
3936
typedef basic_client_impl<Tag,version_major,version_minor> pimpl_type;
4037
typedef basic_client_facade<Tag, basic_client<Tag,version_major,version_minor> > base_facade_type;
4138
public:
42-
typedef basic_request<typename sync_only<Tag>::type> request;
39+
typedef basic_request<Tag> request;
4340
typedef basic_response<Tag> response;
4441
typedeftypename string<Tag>::type string_type;
4542
typedef Tag tag_type;

‎boost/network/protocol/http/client/async_impl.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include<boost/asio/strand.hpp>
1111
#include<boost/thread/thread.hpp>
1212
#include<boost/bind.hpp>
13-
#include<boost/network/support/sync_only.hpp>
1413

1514
namespaceboost {namespacenetwork {namespacehttp {
1615

@@ -56,7 +55,7 @@ namespace boost { namespace network { namespace http {
5655
}
5756

5857
basic_response<Tag>constrequest_skeleton(
59-
basic_request<typename sync_only<Tag>::type>const & request_,
58+
basic_request<Tag>const & request_,
6059
string_typeconst & method,
6160
bool get_body
6261
)

‎boost/network/protocol/http/client/facade.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include<boost/network/protocol/http/request.hpp>
1010
#include<boost/network/protocol/http/response.hpp>
11-
#include<boost/network/protocol/http/support/sync_only.hpp>
1211

1312
namespaceboost {namespacenetwork {namespacehttp {
1413

@@ -22,7 +21,7 @@ namespace boost { namespace network { namespace http {
2221
structbasic_client_facade {
2322

2423
typedeftypename string<Tag>::type string_type;
25-
typedef basic_request<typename sync_only<Tag>::type> request;
24+
typedef basic_request<Tag> request;
2625
typedef basic_response<Tag> response;
2726

2827
basic_client_facade()

‎boost/network/protocol/http/client/pimpl.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include<boost/network/protocol/http/traits/connection_policy.hpp>
1717
#include<boost/network/protocol/http/client/async_impl.hpp>
18-
#include<boost/network/support/sync_only.hpp>
1918

2019
namespaceboost {namespacenetwork {namespacehttp {
2120

@@ -47,7 +46,7 @@ namespace boost { namespace network { namespace http {
4746

4847
~sync_client() {}
4948

50-
basic_response<Tag>constrequest_skeleton(basic_request<typename sync_only<Tag>::type>const & request_, string_type method,bool get_body) {
49+
basic_response<Tag>constrequest_skeleton(basic_request<Tag>const & request_, string_type method,bool get_body) {
5150
typename connection_base::connection_ptr connection_;
5251
connection_ =connection_base::get_connection(resolver_, request_);
5352
return connection_->send_request(method, request_, get_body);

‎boost/network/protocol/http/detail/connection_helper.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include<boost/network/protocol/http/traits/connection_keepalive.hpp>
1212
#include<boost/asio/streambuf.hpp>
1313
#include<boost/network/traits/string.hpp>
14-
#include<boost/network/support/sync_only.hpp>
1514

1615
namespaceboost {namespacenetwork {namespacehttp {namespacedetail {
1716

@@ -21,7 +20,7 @@ namespace boost { namespace network { namespace http { namespace detail {
2120

2221
typedeftypename string<Tag>::type string_type;
2322

24-
voidcreate_request(boost::asio::streambuf & request_buffer, string_typeconst & method, basic_request<typename sync_only<Tag>::type>const & request_)const {
23+
voidcreate_request(boost::asio::streambuf & request_buffer, string_typeconst & method, basic_request<Tag>const & request_)const {
2524
// TODO make this use Boost.Karma instead of an ad-hoc implementation
2625
std::ostreamrequest_stream(&request_buffer);
2726

‎boost/network/protocol/http/impl/async_connection_base.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace boost { namespace network { namespace http { namespace impl {
2121
typedeftypename resolver_base::resolver_type resolver_type;
2222
typedeftypename resolver_base::resolve_function resolve_function;
2323
typedeftypename string<Tag>::type string_type;
24-
typedef basic_request<typename sync_only<Tag>::type> request;
24+
typedef basic_request<Tag> request;
2525
typedef basic_response<Tag> response;
2626

2727
static boost::shared_ptr<async_connection_base<Tag,version_major,version_minor> >new_connection(resolve_function resolve, boost::shared_ptr<resolver_type> resolver,bool follow_redirect,bool https) {

‎boost/network/protocol/http/impl/request.hpp‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include<boost/network/protocol/http/message/async_message.hpp>
2222
#include<boost/network/support/is_async.hpp>
23+
#include<boost/network/protocol/http/support/sync_only.hpp>
2324

2425
#include<boost/cstdint.hpp>
2526

@@ -33,24 +34,15 @@ namespace boost { namespace network { namespace http {
3334
*/
3435

3536
template<classTag>
36-
structrequest_base
37-
: mpl::if_<
38-
is_async<Tag>,
39-
async_message<Tag>,
40-
basic_message<Tag>
41-
>
42-
{};
43-
44-
template<classTag>
45-
structbasic_request :publicrequest_base<Tag>::type
37+
structbasic_request :publicbasic_message<Tag>
4638
{
4739

4840
mutable boost::network::uri::http::uri uri_;
49-
typedeftypename request_base<Tag>::type base_type;
41+
typedefbasic_message<Tag> base_type;
5042

5143
public:
52-
typedef Tag tag;
53-
typedeftypename string<Tag>::type string_type;
44+
typedeftypename sync_only<Tag>::type tag;
45+
typedeftypename string<tag>::type string_type;
5446
typedef boost::uint16_t port_type;
5547

5648
explicitbasic_request(string_typeconst & uri_)

‎boost/network/protocol/http/policies/async_connection.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace boost { namespace network { namespace http {
4141
pimpl = impl::async_connection_base<Tag,version_major,version_minor>::new_connection(resolve, resolver, follow_redirect, https);
4242
}
4343

44-
basic_response<Tag>send_request(string_typeconst & method, basic_request<typename sync_only<Tag>::type>const & request_,bool get_body) {
44+
basic_response<Tag>send_request(string_typeconst & method, basic_request<Tag>const & request_,bool get_body) {
4545
return pimpl->start(request_, method, get_body);
4646
}
4747

@@ -52,7 +52,7 @@ namespace boost { namespace network { namespace http {
5252
};
5353

5454
typedef boost::shared_ptr<connection_impl> connection_ptr;
55-
connection_ptrget_connection(boost::shared_ptr<resolver_type> resolver, basic_request<typename sync_only<Tag>::type>const & request_) {
55+
connection_ptrget_connection(boost::shared_ptr<resolver_type> resolver, basic_request<Tag>const & request_) {
5656
string_type protocol_ =protocol(request_);
5757
connection_ptrconnection_(
5858
newconnection_impl(

‎boost/network/tags.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ namespace boost { namespace network { namespace tags {
3030
// Tag Definition Macro Helper
3131
#ifndef BOOST_NETWORK_DEFINE_TAG
3232
#defineBOOST_NETWORK_DEFINE_TAG(name) \
33-
typedefmpl::inherit_linearly< \
33+
structname :mpl::inherit_linearly< \
3434
name##_tags, \
3535
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2> \
36-
>::typename; \
37-
template<>structcomponents<name> { \
36+
>::type{}; \
37+
template<>structcomponents<name> {\
3838
typedef name##_tags type; \
3939
};
4040
#endif// BOOST_NETWORK_DEFINE_TAG

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp