ゴミ箱
boost::beast::has_get_io_service< T, class > Struct Template Reference

#include <type_traits.hpp>

Inheritance diagram for boost::beast::has_get_io_service< T, class >:

Detailed Description

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)
{
// T does not have get_io_service
}
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");

The documentation for this struct was generated from the following file: