template<class T, class = void>
struct boost::beast::has_get_io_service< T, class >
Determine if T
has the get_io_service
member.
Metafunctions are used to perform compile time checking of template types. This type will be std::true_type
if T
has the member function with the correct signature, else type will be std::false_type
.
- Example
Use with tag dispatching:
template<class T>
void maybe_hello(T& t, std::true_type)
{
t.get_io_service().post([]{ std::cout << "Hello, world!" << std::endl; });
}
template<class T>
void maybe_hello(T&, std::false_type)
{
}
template<class T>
void maybe_hello(T& t)
{
maybe_hello(t, has_get_io_service<T>{});
}
Use with static_assert
:
struct stream
{
boost::asio::io_service& get_io_service();
};
static_assert(has_get_io_service<stream>::value,
"Missing get_io_service member");