| Home | Libraries | People | FAQ | More

#### has_get_executor

Determine if `T` has the `get_executor` member function.

##### Synopsis

Defined in header `<boost/beast/core/type_traits.hpp>`

    template<
        class T>
    struct has_get_executor :
        public std::integral_constant< bool,...>

##### Description

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)
    {
        boost::asio::post(
            t.get_executor(),
            []
            {
                std::cout << "Hello, world!" << std::endl;
            });
    }

    template<class T>
    void maybe_hello(T&, std::false_type)
    {
        // T does not have get_executor
    }

    template<class T>
    void maybe_hello(T& t)
    {
        maybe_hello(t, has_get_executor<T>{});
    }

Use with `static_assert`:

    struct stream
    {
        using executor_type = boost::asio::io_context::executor_type;
        executor_type get_executor() noexcept;
    };

    static_assert(has_get_executor<stream>::value, "Missing get_executor member");

Convenience header `<boost/beast/core.hpp>`