Skip to content

Commit ba96b4f

Browse files
committed
SFINAE-ize the server_base metafunction
The server_base metafunction type serves as a means for choosing which implementation base the server will be deriving from. The SFINAE technique is used to enable the appropriate implementation of the type depending on the tag dispatch mechanism being utilized throughout the implementation.
1 parent 9b9bd9b commit ba96b4f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

boost/network/protocol/http/server.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
#include <boost/network/protocol/http/server/parameters.hpp>
1717

1818
namespace boost { namespace network { namespace http {
19-
19+
20+
template <class Tag, class Handler, class Enable = void>
21+
struct server_base {
22+
typedef unsupported_tag<Tag> type;
23+
};
24+
2025
template <class Tag, class Handler>
21-
struct server_base :
22-
mpl::if_<
23-
is_async<Tag>
24-
, async_server_base<Tag, Handler>
25-
, typename mpl::if_<
26-
is_sync<Tag>
27-
, sync_server_base<Tag, Handler>
28-
, unsupported_tag<Tag>
29-
>::type
30-
>
31-
{};
26+
struct server_base<Tag, Handler, typename enable_if<is_async<Tag> >::type> {
27+
typedef async_server_base<Tag, Handler> type;
28+
};
29+
30+
template <class Tag, class Handler>
31+
struct server_base<Tag, Handler, typename enable_if<is_sync<Tag> >::type> {
32+
typedef sync_server_base<Tag, Handler> type;
33+
};
3234

3335
template <class Tag, class Handler>
3436
struct basic_server : server_base<Tag, Handler>::type

0 commit comments

Comments
 (0)