Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline
- net::io_context*
- get_io_context(net::io_context& ioc)
- {
- return &ioc;
- }
- inline
- net::io_context*
- get_io_context(net::io_context::executor_type const& ex)
- {
- return &ex.context();
- }
- inline
- net::io_context*
- get_io_context(net::strand<
- net::io_context::executor_type> const& ex)
- {
- return &ex.get_inner_executor().context();
- }
- template<class Executor>
- net::io_context*
- get_io_context(net::strand<Executor> const& ex)
- {
- return get_io_context(ex.get_inner_executor());
- }
- template<
- class T,
- class = typename std::enable_if<
- std::is_same<T, net::executor>::value>::type>
- net::io_context*
- get_io_context(T const& ex)
- {
- auto p = ex.target<
- net::io_context::executor_type>();
- if(! p)
- return nullptr;
- return &p->context();
- }
- inline
- net::io_context*
- get_io_context(...)
- {
- return nullptr;
- }
- //------------------------------------------------------------------------------
- template<class T>
- net::io_context*
- get_io_context_impl(T& t, std::true_type)
- {
- return get_io_context(
- t.get_executor());
- }
- template<class T>
- net::io_context*
- get_io_context_impl(T const&, std::false_type)
- {
- return nullptr;
- }
- // Returns the io_context*, or nullptr, for any object.
- template<class T>
- net::io_context*
- get_io_context(T& t)
- {
- return get_io_context_impl(t,
- has_get_executor<T>{});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement