#ifndef BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP
#define BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/context.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
template <typename U>
struct context_as_t
{
template <typename T>
static constexpr bool is_applicable_property_v = is_executor_v<T>;
static constexpr bool is_requirable = false;
static constexpr bool is_preferable = false;
typedef T polymorphic_query_result_type;
};
template <typename U>
constexpr context_as_t context_as;
}
#else
namespace execution {
template <typename T>
struct context_as_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename U>
static constexpr bool is_applicable_property_v = is_executor<U>::value;
#endif
static constexpr bool is_requirable = false;
static constexpr bool is_preferable = false;
typedef T polymorphic_query_result_type;
constexpr context_as_t()
{
}
constexpr context_as_t(context_t)
{
}
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename E>
static constexpr
typename context_t::query_static_constexpr_member<E>::result_type
static_query()
noexcept(context_t::query_static_constexpr_member<E>::is_noexcept)
{
return context_t::query_static_constexpr_member<E>::value();
}
template <typename E, typename U = decltype(context_as_t::static_query<E>())>
static constexpr const U static_query_v
= context_as_t::static_query<E>();
#endif
template <typename Executor, typename U>
friend constexpr U query(
const Executor& ex, const context_as_t<U>&,
enable_if_t<
is_same<T, U>::value
>* = 0,
enable_if_t<
can_query<const Executor&, const context_t&>::value
>* = 0)
#if !defined(__clang__)
#if defined(BOOST_ASIO_MSVC)
noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
#else
noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
#endif #endif {
return boost::asio::query(ex, context);
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T> template <typename E, typename U>
const U context_as_t<T>::static_query_v;
#endif
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) \
|| defined(GENERATING_DOCUMENTATION)
template <typename T>
constexpr context_as_t<T> context_as{};
#endif
}
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename U>
struct is_applicable_property<T, execution::context_as_t<U>>
: integral_constant<bool, execution::is_executor<T>::value>
{
};
#endif
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T, typename U>
struct static_query<T, execution::context_as_t<U>,
enable_if_t<
static_query<T, execution::context_t>::is_valid
>> : static_query<T, execution::context_t>
{
};
#endif
#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
template <typename T, typename U>
struct query_free<T, execution::context_as_t<U>,
enable_if_t<
can_query<const T&, const execution::context_t&>::value
>>
{
static constexpr bool is_valid = true;
static constexpr bool is_noexcept =
is_nothrow_query<const T&, const execution::context_t&>::value;
typedef U result_type;
};
#endif
}
#endif
} }
#include <boost/asio/detail/pop_options.hpp>
#endif