#ifndef BOOST_ASIO_EXECUTION_OCCUPANCY_HPP
#define BOOST_ASIO_EXECUTION_OCCUPANCY_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/executor.hpp>
#include <boost/asio/is_applicable_property.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 {
struct occupancy_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 std::size_t polymorphic_query_result_type;
};
constexpr occupancy_t occupancy;
}
#else
namespace execution {
namespace detail {
template <int I = 0>
struct occupancy_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
static constexpr bool is_applicable_property_v = is_executor<T>::value;
#endif
static constexpr bool is_requirable = false;
static constexpr bool is_preferable = false;
typedef std::size_t polymorphic_query_result_type;
constexpr occupancy_t()
{
}
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(P&& p)
noexcept(
noexcept(
conditional_t<true, T, P>::query(static_cast<P&&>(p))
)
)
-> decltype(
conditional_t<true, T, P>::query(static_cast<P&&>(p))
)
{
return T::query(static_cast<P&&>(p));
}
};
#else
typedef T type;
#endif };
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, occupancy_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static constexpr typename query_static_constexpr_member<T>::result_type
static_query()
noexcept(query_static_constexpr_member<T>::is_noexcept)
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(occupancy_t::static_query<E>())>
static constexpr const T static_query_v = occupancy_t::static_query<E>();
#endif };
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T occupancy_t<I>::static_query_v;
#endif
}
typedef detail::occupancy_t<> occupancy_t;
BOOST_ASIO_INLINE_VARIABLE constexpr occupancy_t occupancy;
}
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
struct is_applicable_property<T, execution::occupancy_t>
: 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>
struct static_query<T, execution::occupancy_t,
enable_if_t<
execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::is_valid
>>
{
static constexpr bool is_valid = true;
static constexpr bool is_noexcept = true;
typedef typename execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static constexpr result_type value()
{
return execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::value();
}
};
#endif
}
#endif
} }
#include <boost/asio/detail/pop_options.hpp>
#endif