Initial Commit
This commit is contained in:
278
include/asio/execution/allocator.hpp
Normal file
278
include/asio/execution/allocator.hpp
Normal file
@@ -0,0 +1,278 @@
|
||||
//
|
||||
// execution/allocator.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_ALLOCATOR_HPP
|
||||
#define ASIO_EXECUTION_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property to describe which allocator an executor will use to allocate the
|
||||
/// memory required to store a submitted function object.
|
||||
template <typename ProtoAllocator>
|
||||
struct allocator_t
|
||||
{
|
||||
/// The allocator_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The allocator_t property can be required.
|
||||
static constexpr bool is_requirable = true;
|
||||
|
||||
/// The allocator_t property can be preferred.
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr allocator_t();
|
||||
|
||||
/// Obtain the allocator stored in the allocator_t property object.
|
||||
/**
|
||||
* Present only if @c ProtoAllocator is non-void.
|
||||
*/
|
||||
constexpr ProtoAllocator value() const;
|
||||
|
||||
/// Create an allocator_t object with a different allocator.
|
||||
/**
|
||||
* Present only if @c ProtoAllocator is void.
|
||||
*/
|
||||
template <typename OtherAllocator>
|
||||
allocator_t<OtherAllocator operator()(const OtherAllocator& a);
|
||||
};
|
||||
|
||||
/// A special value used for accessing the allocator_t property.
|
||||
constexpr allocator_t<void> allocator;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
template <typename ProtoAllocator>
|
||||
struct allocator_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
template <typename T>
|
||||
struct static_proxy
|
||||
{
|
||||
#if defined(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, allocator_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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(allocator_t::static_query<E>())>
|
||||
static constexpr const T static_query_v = allocator_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
constexpr ProtoAllocator value() const
|
||||
{
|
||||
return a_;
|
||||
}
|
||||
|
||||
private:
|
||||
friend struct allocator_t<void>;
|
||||
|
||||
explicit constexpr allocator_t(const ProtoAllocator& a)
|
||||
: a_(a)
|
||||
{
|
||||
}
|
||||
|
||||
ProtoAllocator a_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <typename ProtoAllocator> template <typename E, typename T>
|
||||
const T allocator_t<ProtoAllocator>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <>
|
||||
struct allocator_t<void>
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
constexpr allocator_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct static_proxy
|
||||
{
|
||||
#if defined(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, allocator_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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(allocator_t::static_query<E>())>
|
||||
static constexpr const T static_query_v = allocator_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename OtherProtoAllocator>
|
||||
constexpr allocator_t<OtherProtoAllocator> operator()(
|
||||
const OtherProtoAllocator& a) const
|
||||
{
|
||||
return allocator_t<OtherProtoAllocator>(a);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <typename E, typename T>
|
||||
const T allocator_t<void>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
ASIO_INLINE_VARIABLE constexpr allocator_t<void> allocator;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename ProtoAllocator>
|
||||
struct is_applicable_property<T, execution::allocator_t<ProtoAllocator>>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename ProtoAllocator>
|
||||
struct static_query<T, execution::allocator_t<ProtoAllocator>,
|
||||
enable_if_t<
|
||||
execution::allocator_t<ProtoAllocator>::template
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef typename execution::allocator_t<ProtoAllocator>::template
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::allocator_t<ProtoAllocator>::template
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_ALLOCATOR_HPP
|
||||
1933
include/asio/execution/any_executor.hpp
Normal file
1933
include/asio/execution/any_executor.hpp
Normal file
File diff suppressed because it is too large
Load Diff
46
include/asio/execution/bad_executor.hpp
Normal file
46
include/asio/execution/bad_executor.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// execution/bad_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_BAD_EXECUTOR_HPP
|
||||
#define ASIO_EXECUTION_BAD_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <exception>
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace execution {
|
||||
|
||||
/// Exception thrown when trying to access an empty polymorphic executor.
|
||||
class bad_executor
|
||||
: public std::exception
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
ASIO_DECL bad_executor() noexcept;
|
||||
|
||||
/// Obtain message associated with exception.
|
||||
ASIO_DECL virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
} // namespace execution
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#if defined(ASIO_HEADER_ONLY)
|
||||
# include "asio/execution/impl/bad_executor.ipp"
|
||||
#endif // defined(ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // ASIO_EXECUTION_BAD_EXECUTOR_HPP
|
||||
1360
include/asio/execution/blocking.hpp
Normal file
1360
include/asio/execution/blocking.hpp
Normal file
File diff suppressed because it is too large
Load Diff
1119
include/asio/execution/blocking_adaptation.hpp
Normal file
1119
include/asio/execution/blocking_adaptation.hpp
Normal file
File diff suppressed because it is too large
Load Diff
191
include/asio/execution/context.hpp
Normal file
191
include/asio/execution/context.hpp
Normal file
@@ -0,0 +1,191 @@
|
||||
//
|
||||
// execution/context.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_CONTEXT2_HPP
|
||||
#define ASIO_EXECUTION_CONTEXT2_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_STD_ANY)
|
||||
# include <any>
|
||||
#endif // defined(ASIO_HAS_STD_ANY)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property that is used to obtain the execution context that is associated
|
||||
/// with an executor.
|
||||
struct context_t
|
||||
{
|
||||
/// The context_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The context_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The context_t property cannot be preferred.
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef std::any polymorphic_query_result_type;
|
||||
};
|
||||
|
||||
/// A special value used for accessing the context_t property.
|
||||
constexpr context_t context;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
|
||||
template <int I = 0>
|
||||
struct context_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = false;
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
#if defined(ASIO_HAS_STD_ANY)
|
||||
typedef std::any polymorphic_query_result_type;
|
||||
#endif // defined(ASIO_HAS_STD_ANY)
|
||||
|
||||
constexpr context_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct static_proxy
|
||||
{
|
||||
#if defined(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, context_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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(context_t::static_query<E>())>
|
||||
static constexpr const T static_query_v = context_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T context_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
typedef detail::context_t<> context_t;
|
||||
|
||||
ASIO_INLINE_VARIABLE constexpr context_t context;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::context_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::context_t,
|
||||
enable_if_t<
|
||||
execution::detail::context_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::context_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::context_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_CONTEXT2_HPP
|
||||
190
include/asio/execution/context_as.hpp
Normal file
190
include/asio/execution/context_as.hpp
Normal file
@@ -0,0 +1,190 @@
|
||||
//
|
||||
// execution/context_as.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_CONTEXT_AS_HPP
|
||||
#define ASIO_EXECUTION_CONTEXT_AS_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/context.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/query.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property that is used to obtain the execution context that is associated
|
||||
/// with an executor.
|
||||
template <typename U>
|
||||
struct context_as_t
|
||||
{
|
||||
/// The context_as_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The context_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The context_t property cannot be preferred.
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef T polymorphic_query_result_type;
|
||||
};
|
||||
|
||||
/// A special value used for accessing the context_as_t property.
|
||||
template <typename U>
|
||||
constexpr context_as_t context_as;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
template <typename T>
|
||||
struct context_as_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename U>
|
||||
static constexpr bool is_applicable_property_v = is_executor<U>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
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(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
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__) // Clang crashes if noexcept is used here.
|
||||
#if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
|
||||
noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
|
||||
#else // defined(ASIO_MSVC)
|
||||
noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
|
||||
#endif // defined(ASIO_MSVC)
|
||||
#endif // !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, context);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <typename T> template <typename E, typename U>
|
||||
const U context_as_t<T>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
template <typename T>
|
||||
constexpr context_as_t<T> context_as{};
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(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 // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(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 // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
#if !defined(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 // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_CONTEXT_AS_HPP
|
||||
116
include/asio/execution/executor.hpp
Normal file
116
include/asio/execution/executor.hpp
Normal file
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// execution/executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_EXECUTOR_HPP
|
||||
#define ASIO_EXECUTION_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/invocable_archetype.hpp"
|
||||
#include "asio/traits/equality_comparable.hpp"
|
||||
#include "asio/traits/execute_member.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
# define ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT 1
|
||||
#endif // defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename F,
|
||||
typename = void, typename = void, typename = void, typename = void,
|
||||
typename = void, typename = void, typename = void, typename = void>
|
||||
struct is_executor_of_impl : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename F>
|
||||
struct is_executor_of_impl<T, F,
|
||||
enable_if_t<
|
||||
traits::execute_member<add_const_t<T>, F>::is_valid
|
||||
>,
|
||||
void_t<
|
||||
result_of_t<decay_t<F>&()>
|
||||
>,
|
||||
enable_if_t<
|
||||
is_constructible<decay_t<F>, F>::value
|
||||
>,
|
||||
enable_if_t<
|
||||
is_move_constructible<decay_t<F>>::value
|
||||
>,
|
||||
enable_if_t<
|
||||
is_nothrow_copy_constructible<T>::value
|
||||
>,
|
||||
enable_if_t<
|
||||
is_nothrow_destructible<T>::value
|
||||
>,
|
||||
enable_if_t<
|
||||
traits::equality_comparable<T>::is_valid
|
||||
>,
|
||||
enable_if_t<
|
||||
traits::equality_comparable<T>::is_noexcept
|
||||
>> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The is_executor trait detects whether a type T satisfies the
|
||||
/// execution::executor concept.
|
||||
/**
|
||||
* Class template @c is_executor is a UnaryTypeTrait that is derived from @c
|
||||
* true_type if the type @c T meets the concept definition for an executor,
|
||||
* otherwise @c false_type.
|
||||
*/
|
||||
template <typename T>
|
||||
struct is_executor :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool, automatically_determined>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
detail::is_executor_of_impl<T, invocable_archetype>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
constexpr const bool is_executor_v = is_executor<T>::value;
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
template <typename T>
|
||||
ASIO_CONCEPT executor = is_executor<T>::value;
|
||||
|
||||
#define ASIO_EXECUTION_EXECUTOR ::asio::execution::executor
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_EXECUTION_EXECUTOR typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
} // namespace execution
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_EXECUTOR_HPP
|
||||
40
include/asio/execution/impl/bad_executor.ipp
Normal file
40
include/asio/execution/impl/bad_executor.ipp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// execution/impl/bad_executor.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP
|
||||
#define ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/execution/bad_executor.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace execution {
|
||||
|
||||
bad_executor::bad_executor() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
const char* bad_executor::what() const noexcept
|
||||
{
|
||||
return "bad executor";
|
||||
}
|
||||
|
||||
} // namespace execution
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP
|
||||
43
include/asio/execution/invocable_archetype.hpp
Normal file
43
include/asio/execution/invocable_archetype.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// execution/invocable_archetype.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP
|
||||
#define ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace execution {
|
||||
|
||||
/// An archetypal function object used for determining adherence to the
|
||||
/// execution::executor concept.
|
||||
struct invocable_archetype
|
||||
{
|
||||
/// Function call operator.
|
||||
template <typename... Args>
|
||||
void operator()(Args&&...)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace execution
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP
|
||||
|
||||
1002
include/asio/execution/mapping.hpp
Normal file
1002
include/asio/execution/mapping.hpp
Normal file
File diff suppressed because it is too large
Load Diff
184
include/asio/execution/occupancy.hpp
Normal file
184
include/asio/execution/occupancy.hpp
Normal file
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// execution/occupancy.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_OCCUPANCY_HPP
|
||||
#define ASIO_EXECUTION_OCCUPANCY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property that gives an estimate of the number of execution agents that
|
||||
/// should occupy the associated execution context.
|
||||
struct occupancy_t
|
||||
{
|
||||
/// The occupancy_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The occupancy_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The occupancy_t property cannot be preferred.
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef std::size_t polymorphic_query_result_type;
|
||||
};
|
||||
|
||||
/// A special value used for accessing the occupancy_t property.
|
||||
constexpr occupancy_t occupancy;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
|
||||
template <int I = 0>
|
||||
struct occupancy_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
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(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, occupancy_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T occupancy_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
typedef detail::occupancy_t<> occupancy_t;
|
||||
|
||||
ASIO_INLINE_VARIABLE constexpr occupancy_t occupancy;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::occupancy_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(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 // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_OCCUPANCY_HPP
|
||||
753
include/asio/execution/outstanding_work.hpp
Normal file
753
include/asio/execution/outstanding_work.hpp
Normal file
@@ -0,0 +1,753 @@
|
||||
//
|
||||
// execution/outstanding_work.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_OUTSTANDING_WORK_HPP
|
||||
#define ASIO_EXECUTION_OUTSTANDING_WORK_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/query.hpp"
|
||||
#include "asio/traits/query_free.hpp"
|
||||
#include "asio/traits/query_member.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
#include "asio/traits/static_require.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property to describe whether task submission is likely in the future.
|
||||
struct outstanding_work_t
|
||||
{
|
||||
/// The outstanding_work_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The top-level outstanding_work_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The top-level outstanding_work_t property cannot be preferred.
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef outstanding_work_t polymorphic_query_result_type;
|
||||
|
||||
/// A sub-property that indicates that the executor does not represent likely
|
||||
/// future submission of a function object.
|
||||
struct untracked_t
|
||||
{
|
||||
/// The outstanding_work_t::untracked_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The outstanding_work_t::untracked_t property can be required.
|
||||
static constexpr bool is_requirable = true;
|
||||
|
||||
/// The outstanding_work_t::untracked_t property can be preferred.
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef outstanding_work_t polymorphic_query_result_type;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr untracked_t();
|
||||
|
||||
/// Get the value associated with a property object.
|
||||
/**
|
||||
* @returns untracked_t();
|
||||
*/
|
||||
static constexpr outstanding_work_t value();
|
||||
};
|
||||
|
||||
/// A sub-property that indicates that the executor represents likely
|
||||
/// future submission of a function object.
|
||||
struct tracked_t
|
||||
{
|
||||
/// The outstanding_work_t::untracked_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The outstanding_work_t::tracked_t property can be required.
|
||||
static constexpr bool is_requirable = true;
|
||||
|
||||
/// The outstanding_work_t::tracked_t property can be preferred.
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef outstanding_work_t polymorphic_query_result_type;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr tracked_t();
|
||||
|
||||
/// Get the value associated with a property object.
|
||||
/**
|
||||
* @returns tracked_t();
|
||||
*/
|
||||
static constexpr outstanding_work_t value();
|
||||
};
|
||||
|
||||
/// A special value used for accessing the outstanding_work_t::untracked_t
|
||||
/// property.
|
||||
static constexpr untracked_t untracked;
|
||||
|
||||
/// A special value used for accessing the outstanding_work_t::tracked_t
|
||||
/// property.
|
||||
static constexpr tracked_t tracked;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr outstanding_work_t();
|
||||
|
||||
/// Construct from a sub-property value.
|
||||
constexpr outstanding_work_t(untracked_t);
|
||||
|
||||
/// Construct from a sub-property value.
|
||||
constexpr outstanding_work_t(tracked_t);
|
||||
|
||||
/// Compare property values for equality.
|
||||
friend constexpr bool operator==(
|
||||
const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
|
||||
|
||||
/// Compare property values for inequality.
|
||||
friend constexpr bool operator!=(
|
||||
const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
|
||||
};
|
||||
|
||||
/// A special value used for accessing the outstanding_work_t property.
|
||||
constexpr outstanding_work_t outstanding_work;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
namespace outstanding_work {
|
||||
|
||||
template <int I> struct untracked_t;
|
||||
template <int I> struct tracked_t;
|
||||
|
||||
} // namespace outstanding_work
|
||||
|
||||
template <int I = 0>
|
||||
struct outstanding_work_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = false;
|
||||
static constexpr bool is_preferable = false;
|
||||
typedef outstanding_work_t polymorphic_query_result_type;
|
||||
|
||||
typedef detail::outstanding_work::untracked_t<I> untracked_t;
|
||||
typedef detail::outstanding_work::tracked_t<I> tracked_t;
|
||||
|
||||
constexpr outstanding_work_t()
|
||||
: value_(-1)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr outstanding_work_t(untracked_t)
|
||||
: value_(0)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr outstanding_work_t(tracked_t)
|
||||
: value_(1)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct proxy
|
||||
{
|
||||
#if defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
struct type
|
||||
{
|
||||
template <typename P>
|
||||
auto query(P&& p) const
|
||||
noexcept(
|
||||
noexcept(
|
||||
declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
|
||||
)
|
||||
)
|
||||
-> decltype(
|
||||
declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
|
||||
);
|
||||
};
|
||||
#else // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_proxy
|
||||
{
|
||||
#if defined(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<typename proxy<T>::type, outstanding_work_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, outstanding_work_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 T>
|
||||
static constexpr
|
||||
typename traits::static_query<T, untracked_t>::result_type
|
||||
static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
traits::static_query<T, untracked_t>::is_valid
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return traits::static_query<T, untracked_t>::value();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr
|
||||
typename traits::static_query<T, tracked_t>::result_type
|
||||
static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!traits::static_query<T, untracked_t>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
traits::static_query<T, tracked_t>::is_valid
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return traits::static_query<T, tracked_t>::value();
|
||||
}
|
||||
|
||||
template <typename E,
|
||||
typename T = decltype(outstanding_work_t::static_query<E>())>
|
||||
static constexpr const T static_query_v
|
||||
= outstanding_work_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
friend constexpr bool operator==(
|
||||
const outstanding_work_t& a, const outstanding_work_t& b)
|
||||
{
|
||||
return a.value_ == b.value_;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(
|
||||
const outstanding_work_t& a, const outstanding_work_t& b)
|
||||
{
|
||||
return a.value_ != b.value_;
|
||||
}
|
||||
|
||||
struct convertible_from_outstanding_work_t
|
||||
{
|
||||
constexpr convertible_from_outstanding_work_t(outstanding_work_t)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
friend constexpr outstanding_work_t query(
|
||||
const Executor& ex, convertible_from_outstanding_work_t,
|
||||
enable_if_t<
|
||||
can_query<const Executor&, untracked_t>::value
|
||||
>* = 0)
|
||||
#if !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
#if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
|
||||
noexcept(is_nothrow_query<const Executor&,
|
||||
outstanding_work_t<>::untracked_t>::value)
|
||||
#else // defined(ASIO_MSVC)
|
||||
noexcept(is_nothrow_query<const Executor&, untracked_t>::value)
|
||||
#endif // defined(ASIO_MSVC)
|
||||
#endif // !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, untracked_t());
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
friend constexpr outstanding_work_t query(
|
||||
const Executor& ex, convertible_from_outstanding_work_t,
|
||||
enable_if_t<
|
||||
!can_query<const Executor&, untracked_t>::value
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
can_query<const Executor&, tracked_t>::value
|
||||
>* = 0)
|
||||
#if !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
#if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
|
||||
noexcept(is_nothrow_query<const Executor&,
|
||||
outstanding_work_t<>::tracked_t>::value)
|
||||
#else // defined(ASIO_MSVC)
|
||||
noexcept(is_nothrow_query<const Executor&, tracked_t>::value)
|
||||
#endif // defined(ASIO_MSVC)
|
||||
#endif // !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, tracked_t());
|
||||
}
|
||||
|
||||
ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(untracked_t, untracked);
|
||||
ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(tracked_t, tracked);
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T outstanding_work_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <int I>
|
||||
const typename outstanding_work_t<I>::untracked_t
|
||||
outstanding_work_t<I>::untracked;
|
||||
|
||||
template <int I>
|
||||
const typename outstanding_work_t<I>::tracked_t
|
||||
outstanding_work_t<I>::tracked;
|
||||
|
||||
namespace outstanding_work {
|
||||
|
||||
template <int I = 0>
|
||||
struct untracked_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
typedef outstanding_work_t<I> polymorphic_query_result_type;
|
||||
|
||||
constexpr untracked_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<
|
||||
typename outstanding_work_t<I>::template proxy<T>::type, untracked_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename outstanding_work_t<I>::template static_proxy<T>::type,
|
||||
untracked_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 T>
|
||||
static constexpr untracked_t static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!traits::query_free<T, untracked_t>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!can_query<T, tracked_t<I>>::value
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return untracked_t();
|
||||
}
|
||||
|
||||
template <typename E, typename T = decltype(untracked_t::static_query<E>())>
|
||||
static constexpr const T static_query_v = untracked_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr outstanding_work_t<I> value()
|
||||
{
|
||||
return untracked_t();
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const untracked_t&, const untracked_t&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const untracked_t&, const untracked_t&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const untracked_t&, const tracked_t<I>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const untracked_t&, const tracked_t<I>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T untracked_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <int I = 0>
|
||||
struct tracked_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
typedef outstanding_work_t<I> polymorphic_query_result_type;
|
||||
|
||||
constexpr tracked_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<
|
||||
typename outstanding_work_t<I>::template proxy<T>::type, tracked_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename outstanding_work_t<I>::template static_proxy<T>::type,
|
||||
tracked_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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(tracked_t::static_query<E>())>
|
||||
static constexpr const T static_query_v = tracked_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr outstanding_work_t<I> value()
|
||||
{
|
||||
return tracked_t();
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const tracked_t&, const tracked_t&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const tracked_t&, const tracked_t&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const tracked_t&, const untracked_t<I>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const tracked_t&, const untracked_t<I>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T tracked_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace outstanding_work
|
||||
} // namespace detail
|
||||
|
||||
typedef detail::outstanding_work_t<> outstanding_work_t;
|
||||
|
||||
ASIO_INLINE_VARIABLE constexpr outstanding_work_t outstanding_work;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::outstanding_work_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::outstanding_work_t::untracked_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::outstanding_work_t::tracked_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
template <typename T>
|
||||
struct query_free_default<T, execution::outstanding_work_t,
|
||||
enable_if_t<
|
||||
can_query<T, execution::outstanding_work_t::untracked_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_query<T, execution::outstanding_work_t::untracked_t>::value;
|
||||
|
||||
typedef execution::outstanding_work_t result_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_free_default<T, execution::outstanding_work_t,
|
||||
enable_if_t<
|
||||
!can_query<T, execution::outstanding_work_t::untracked_t>::value
|
||||
&& can_query<T, execution::outstanding_work_t::tracked_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_query<T, execution::outstanding_work_t::tracked_t>::value;
|
||||
|
||||
typedef execution::outstanding_work_t result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t,
|
||||
enable_if_t<
|
||||
execution::detail::outstanding_work_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::outstanding_work_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::outstanding_work_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t,
|
||||
enable_if_t<
|
||||
!execution::detail::outstanding_work_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::outstanding_work_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& traits::static_query<T,
|
||||
execution::outstanding_work_t::untracked_t>::is_valid
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef typename traits::static_query<T,
|
||||
execution::outstanding_work_t::untracked_t>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return traits::static_query<T,
|
||||
execution::outstanding_work_t::untracked_t>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t,
|
||||
enable_if_t<
|
||||
!execution::detail::outstanding_work_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::outstanding_work_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& !traits::static_query<T,
|
||||
execution::outstanding_work_t::untracked_t>::is_valid
|
||||
&& traits::static_query<T,
|
||||
execution::outstanding_work_t::tracked_t>::is_valid
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef typename traits::static_query<T,
|
||||
execution::outstanding_work_t::tracked_t>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return traits::static_query<T,
|
||||
execution::outstanding_work_t::tracked_t>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t::untracked_t,
|
||||
enable_if_t<
|
||||
execution::detail::outstanding_work::untracked_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::outstanding_work::untracked_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::outstanding_work::untracked_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t::untracked_t,
|
||||
enable_if_t<
|
||||
!execution::detail::outstanding_work::untracked_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::outstanding_work::untracked_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& !traits::query_free<T,
|
||||
execution::outstanding_work_t::untracked_t>::is_valid
|
||||
&& !can_query<T, execution::outstanding_work_t::tracked_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef execution::outstanding_work_t::untracked_t result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::outstanding_work_t::tracked_t,
|
||||
enable_if_t<
|
||||
execution::detail::outstanding_work::tracked_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::outstanding_work::tracked_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::outstanding_work::tracked_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_OUTSTANDING_WORK_HPP
|
||||
328
include/asio/execution/prefer_only.hpp
Normal file
328
include/asio/execution/prefer_only.hpp
Normal file
@@ -0,0 +1,328 @@
|
||||
//
|
||||
// execution/prefer_only.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_PREFER_ONLY_HPP
|
||||
#define ASIO_EXECUTION_PREFER_ONLY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/prefer.hpp"
|
||||
#include "asio/query.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property adapter that is used with the polymorphic executor wrapper
|
||||
/// to mark properties as preferable, but not requirable.
|
||||
template <typename Property>
|
||||
struct prefer_only
|
||||
{
|
||||
/// The prefer_only adapter applies to the same types as the nested property.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v =
|
||||
is_applicable_property<T, Property>::value;
|
||||
|
||||
/// The context_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The context_t property can be preferred, it the underlying property can
|
||||
/// be preferred.
|
||||
/**
|
||||
* @c true if @c Property::is_preferable is @c true, otherwise @c false.
|
||||
*/
|
||||
static constexpr bool is_preferable = automatically_determined;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef typename Property::polymorphic_query_result_type
|
||||
polymorphic_query_result_type;
|
||||
};
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
|
||||
template <typename InnerProperty, typename = void>
|
||||
struct prefer_only_is_preferable
|
||||
{
|
||||
static constexpr bool is_preferable = false;
|
||||
};
|
||||
|
||||
template <typename InnerProperty>
|
||||
struct prefer_only_is_preferable<InnerProperty,
|
||||
enable_if_t<
|
||||
InnerProperty::is_preferable
|
||||
>
|
||||
>
|
||||
{
|
||||
static constexpr bool is_preferable = true;
|
||||
};
|
||||
|
||||
template <typename InnerProperty, typename = void>
|
||||
struct prefer_only_polymorphic_query_result_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename InnerProperty>
|
||||
struct prefer_only_polymorphic_query_result_type<InnerProperty,
|
||||
void_t<
|
||||
typename InnerProperty::polymorphic_query_result_type
|
||||
>
|
||||
>
|
||||
{
|
||||
typedef typename InnerProperty::polymorphic_query_result_type
|
||||
polymorphic_query_result_type;
|
||||
};
|
||||
|
||||
template <typename InnerProperty, typename = void>
|
||||
struct prefer_only_property
|
||||
{
|
||||
InnerProperty property;
|
||||
|
||||
prefer_only_property(const InnerProperty& p)
|
||||
: property(p)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
|
||||
|
||||
template <typename InnerProperty>
|
||||
struct prefer_only_property<InnerProperty,
|
||||
void_t<
|
||||
decltype(asio::declval<const InnerProperty>().value())
|
||||
>
|
||||
>
|
||||
{
|
||||
InnerProperty property;
|
||||
|
||||
prefer_only_property(const InnerProperty& p)
|
||||
: property(p)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr auto value() const
|
||||
noexcept(noexcept(asio::declval<const InnerProperty>().value()))
|
||||
-> decltype(asio::declval<const InnerProperty>().value())
|
||||
{
|
||||
return property.value();
|
||||
}
|
||||
};
|
||||
|
||||
#else // defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
|
||||
|
||||
struct prefer_only_memfns_base
|
||||
{
|
||||
void value();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct prefer_only_memfns_derived
|
||||
: T, prefer_only_memfns_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, T>
|
||||
struct prefer_only_memfns_check
|
||||
{
|
||||
};
|
||||
|
||||
template <typename>
|
||||
char (&prefer_only_value_memfn_helper(...))[2];
|
||||
|
||||
template <typename T>
|
||||
char prefer_only_value_memfn_helper(
|
||||
prefer_only_memfns_check<
|
||||
void (prefer_only_memfns_base::*)(),
|
||||
&prefer_only_memfns_derived<T>::value>*);
|
||||
|
||||
template <typename InnerProperty>
|
||||
struct prefer_only_property<InnerProperty,
|
||||
enable_if_t<
|
||||
sizeof(prefer_only_value_memfn_helper<InnerProperty>(0)) != 1
|
||||
&& !is_same<typename InnerProperty::polymorphic_query_result_type,
|
||||
void>::value
|
||||
>
|
||||
>
|
||||
{
|
||||
InnerProperty property;
|
||||
|
||||
prefer_only_property(const InnerProperty& p)
|
||||
: property(p)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr typename InnerProperty::polymorphic_query_result_type
|
||||
value() const
|
||||
{
|
||||
return property.value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename InnerProperty>
|
||||
struct prefer_only :
|
||||
detail::prefer_only_is_preferable<InnerProperty>,
|
||||
detail::prefer_only_polymorphic_query_result_type<InnerProperty>,
|
||||
detail::prefer_only_property<InnerProperty>
|
||||
{
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
constexpr prefer_only(const InnerProperty& p)
|
||||
: detail::prefer_only_property<InnerProperty>(p)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr
|
||||
typename traits::static_query<T, InnerProperty>::result_type
|
||||
static_query()
|
||||
noexcept(traits::static_query<T, InnerProperty>::is_noexcept)
|
||||
{
|
||||
return traits::static_query<T, InnerProperty>::value();
|
||||
}
|
||||
|
||||
template <typename E, typename T = decltype(prefer_only::static_query<E>())>
|
||||
static constexpr const T static_query_v
|
||||
= prefer_only::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename Executor, typename Property>
|
||||
friend constexpr
|
||||
prefer_result_t<const Executor&, const InnerProperty&>
|
||||
prefer(const Executor& ex, const prefer_only<Property>& p,
|
||||
enable_if_t<
|
||||
is_same<Property, InnerProperty>::value
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
can_prefer<const Executor&, const InnerProperty&>::value
|
||||
>* = 0)
|
||||
#if !defined(ASIO_MSVC) \
|
||||
&& !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
noexcept(is_nothrow_prefer<const Executor&, const InnerProperty&>::value)
|
||||
#endif // !defined(ASIO_MSVC)
|
||||
// && !defined(__clang__)
|
||||
{
|
||||
return asio::prefer(ex, p.property);
|
||||
}
|
||||
|
||||
template <typename Executor, typename Property>
|
||||
friend constexpr
|
||||
query_result_t<const Executor&, const InnerProperty&>
|
||||
query(const Executor& ex, const prefer_only<Property>& p,
|
||||
enable_if_t<
|
||||
is_same<Property, InnerProperty>::value
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
can_query<const Executor&, const InnerProperty&>::value
|
||||
>* = 0)
|
||||
#if !defined(ASIO_MSVC) \
|
||||
&& !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
noexcept(is_nothrow_query<const Executor&, const InnerProperty&>::value)
|
||||
#endif // !defined(ASIO_MSVC)
|
||||
// && !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, p.property);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <typename InnerProperty> template <typename E, typename T>
|
||||
const T prefer_only<InnerProperty>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace execution
|
||||
|
||||
template <typename T, typename InnerProperty>
|
||||
struct is_applicable_property<T, execution::prefer_only<InnerProperty>>
|
||||
: is_applicable_property<T, InnerProperty>
|
||||
{
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename InnerProperty>
|
||||
struct static_query<T, execution::prefer_only<InnerProperty>> :
|
||||
static_query<T, const InnerProperty&>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
|
||||
|
||||
template <typename T, typename InnerProperty>
|
||||
struct prefer_free_default<T, execution::prefer_only<InnerProperty>,
|
||||
enable_if_t<
|
||||
can_prefer<const T&, const InnerProperty&>::value
|
||||
>
|
||||
>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_prefer<const T&, const InnerProperty&>::value;
|
||||
|
||||
typedef prefer_result_t<const T&, const InnerProperty&> result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
template <typename T, typename InnerProperty>
|
||||
struct query_free<T, execution::prefer_only<InnerProperty>,
|
||||
enable_if_t<
|
||||
can_query<const T&, const InnerProperty&>::value
|
||||
>
|
||||
>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_query<const T&, const InnerProperty&>::value;
|
||||
|
||||
typedef query_result_t<const T&, const InnerProperty&> result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_PREFER_ONLY_HPP
|
||||
751
include/asio/execution/relationship.hpp
Normal file
751
include/asio/execution/relationship.hpp
Normal file
@@ -0,0 +1,751 @@
|
||||
//
|
||||
// execution/relationship.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_EXECUTION_RELATIONSHIP_HPP
|
||||
#define ASIO_EXECUTION_RELATIONSHIP_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/query.hpp"
|
||||
#include "asio/traits/query_free.hpp"
|
||||
#include "asio/traits/query_member.hpp"
|
||||
#include "asio/traits/query_static_constexpr_member.hpp"
|
||||
#include "asio/traits/static_query.hpp"
|
||||
#include "asio/traits/static_require.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
|
||||
/// A property to describe whether submitted tasks represent continuations of
|
||||
/// the calling context.
|
||||
struct relationship_t
|
||||
{
|
||||
/// The relationship_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The top-level relationship_t property cannot be required.
|
||||
static constexpr bool is_requirable = false;
|
||||
|
||||
/// The top-level relationship_t property cannot be preferred.
|
||||
static constexpr bool is_preferable = false;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef relationship_t polymorphic_query_result_type;
|
||||
|
||||
/// A sub-property that indicates that the executor does not represent a
|
||||
/// continuation of the calling context.
|
||||
struct fork_t
|
||||
{
|
||||
/// The relationship_t::fork_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The relationship_t::fork_t property can be required.
|
||||
static constexpr bool is_requirable = true;
|
||||
|
||||
/// The relationship_t::fork_t property can be preferred.
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef relationship_t polymorphic_query_result_type;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr fork_t();
|
||||
|
||||
/// Get the value associated with a property object.
|
||||
/**
|
||||
* @returns fork_t();
|
||||
*/
|
||||
static constexpr relationship_t value();
|
||||
};
|
||||
|
||||
/// A sub-property that indicates that the executor represents a continuation
|
||||
/// of the calling context.
|
||||
struct continuation_t
|
||||
{
|
||||
/// The relationship_t::continuation_t property applies to executors.
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor_v<T>;
|
||||
|
||||
/// The relationship_t::continuation_t property can be required.
|
||||
static constexpr bool is_requirable = true;
|
||||
|
||||
/// The relationship_t::continuation_t property can be preferred.
|
||||
static constexpr bool is_preferable = true;
|
||||
|
||||
/// The type returned by queries against an @c any_executor.
|
||||
typedef relationship_t polymorphic_query_result_type;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr continuation_t();
|
||||
|
||||
/// Get the value associated with a property object.
|
||||
/**
|
||||
* @returns continuation_t();
|
||||
*/
|
||||
static constexpr relationship_t value();
|
||||
};
|
||||
|
||||
/// A special value used for accessing the relationship_t::fork_t property.
|
||||
static constexpr fork_t fork;
|
||||
|
||||
/// A special value used for accessing the relationship_t::continuation_t
|
||||
/// property.
|
||||
static constexpr continuation_t continuation;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr relationship_t();
|
||||
|
||||
/// Construct from a sub-property value.
|
||||
constexpr relationship_t(fork_t);
|
||||
|
||||
/// Construct from a sub-property value.
|
||||
constexpr relationship_t(continuation_t);
|
||||
|
||||
/// Compare property values for equality.
|
||||
friend constexpr bool operator==(
|
||||
const relationship_t& a, const relationship_t& b) noexcept;
|
||||
|
||||
/// Compare property values for inequality.
|
||||
friend constexpr bool operator!=(
|
||||
const relationship_t& a, const relationship_t& b) noexcept;
|
||||
};
|
||||
|
||||
/// A special value used for accessing the relationship_t property.
|
||||
constexpr relationship_t relationship;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace execution {
|
||||
namespace detail {
|
||||
namespace relationship {
|
||||
|
||||
template <int I> struct fork_t;
|
||||
template <int I> struct continuation_t;
|
||||
|
||||
} // namespace relationship
|
||||
|
||||
template <int I = 0>
|
||||
struct relationship_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = false;
|
||||
static constexpr bool is_preferable = false;
|
||||
typedef relationship_t polymorphic_query_result_type;
|
||||
|
||||
typedef detail::relationship::fork_t<I> fork_t;
|
||||
typedef detail::relationship::continuation_t<I> continuation_t;
|
||||
|
||||
constexpr relationship_t()
|
||||
: value_(-1)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr relationship_t(fork_t)
|
||||
: value_(0)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr relationship_t(continuation_t)
|
||||
: value_(1)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct proxy
|
||||
{
|
||||
#if defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
struct type
|
||||
{
|
||||
template <typename P>
|
||||
auto query(P&& p) const
|
||||
noexcept(
|
||||
noexcept(
|
||||
declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
|
||||
)
|
||||
)
|
||||
-> decltype(
|
||||
declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
|
||||
);
|
||||
};
|
||||
#else // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_proxy
|
||||
{
|
||||
#if defined(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 // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
typedef T type;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<typename proxy<T>::type, relationship_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename static_proxy<T>::type, relationship_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 T>
|
||||
static constexpr
|
||||
typename traits::static_query<T, fork_t>::result_type
|
||||
static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
traits::static_query<T, fork_t>::is_valid
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return traits::static_query<T, fork_t>::value();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr
|
||||
typename traits::static_query<T, continuation_t>::result_type
|
||||
static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!traits::static_query<T, fork_t>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
traits::static_query<T, continuation_t>::is_valid
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return traits::static_query<T, continuation_t>::value();
|
||||
}
|
||||
|
||||
template <typename E,
|
||||
typename T = decltype(relationship_t::static_query<E>())>
|
||||
static constexpr const T static_query_v
|
||||
= relationship_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
friend constexpr bool operator==(
|
||||
const relationship_t& a, const relationship_t& b)
|
||||
{
|
||||
return a.value_ == b.value_;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(
|
||||
const relationship_t& a, const relationship_t& b)
|
||||
{
|
||||
return a.value_ != b.value_;
|
||||
}
|
||||
|
||||
struct convertible_from_relationship_t
|
||||
{
|
||||
constexpr convertible_from_relationship_t(relationship_t)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
friend constexpr relationship_t query(
|
||||
const Executor& ex, convertible_from_relationship_t,
|
||||
enable_if_t<
|
||||
can_query<const Executor&, fork_t>::value
|
||||
>* = 0)
|
||||
#if !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
#if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
|
||||
noexcept(is_nothrow_query<const Executor&, relationship_t<>::fork_t>::value)
|
||||
#else // defined(ASIO_MSVC)
|
||||
noexcept(is_nothrow_query<const Executor&, fork_t>::value)
|
||||
#endif // defined(ASIO_MSVC)
|
||||
#endif // !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, fork_t());
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
friend constexpr relationship_t query(
|
||||
const Executor& ex, convertible_from_relationship_t,
|
||||
enable_if_t<
|
||||
!can_query<const Executor&, fork_t>::value
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
can_query<const Executor&, continuation_t>::value
|
||||
>* = 0)
|
||||
#if !defined(__clang__) // Clang crashes if noexcept is used here.
|
||||
#if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
|
||||
noexcept(is_nothrow_query<const Executor&,
|
||||
relationship_t<>::continuation_t>::value)
|
||||
#else // defined(ASIO_MSVC)
|
||||
noexcept(is_nothrow_query<const Executor&, continuation_t>::value)
|
||||
#endif // defined(ASIO_MSVC)
|
||||
#endif // !defined(__clang__)
|
||||
{
|
||||
return asio::query(ex, continuation_t());
|
||||
}
|
||||
|
||||
ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(fork_t, fork);
|
||||
ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(continuation_t, continuation);
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T relationship_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <int I>
|
||||
const typename relationship_t<I>::fork_t relationship_t<I>::fork;
|
||||
|
||||
template <int I>
|
||||
const typename relationship_t<I>::continuation_t
|
||||
relationship_t<I>::continuation;
|
||||
|
||||
namespace relationship {
|
||||
|
||||
template <int I = 0>
|
||||
struct fork_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
typedef relationship_t<I> polymorphic_query_result_type;
|
||||
|
||||
constexpr fork_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<
|
||||
typename relationship_t<I>::template proxy<T>::type, fork_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename relationship_t<I>::template static_proxy<T>::type, fork_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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 T>
|
||||
static constexpr fork_t static_query(
|
||||
enable_if_t<
|
||||
!query_static_constexpr_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!query_member<T>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!traits::query_free<T, fork_t>::is_valid
|
||||
>* = 0,
|
||||
enable_if_t<
|
||||
!can_query<T, continuation_t<I>>::value
|
||||
>* = 0) noexcept
|
||||
{
|
||||
return fork_t();
|
||||
}
|
||||
|
||||
template <typename E, typename T = decltype(fork_t::static_query<E>())>
|
||||
static constexpr const T static_query_v
|
||||
= fork_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr relationship_t<I> value()
|
||||
{
|
||||
return fork_t();
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const fork_t&, const fork_t&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const fork_t&, const fork_t&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const fork_t&, const continuation_t<I>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const fork_t&, const continuation_t<I>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T fork_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <int I = 0>
|
||||
struct continuation_t
|
||||
{
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
template <typename T>
|
||||
static constexpr bool is_applicable_property_v = is_executor<T>::value;
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr bool is_requirable = true;
|
||||
static constexpr bool is_preferable = true;
|
||||
typedef relationship_t<I> polymorphic_query_result_type;
|
||||
|
||||
constexpr continuation_t()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct query_member :
|
||||
traits::query_member<
|
||||
typename relationship_t<I>::template proxy<T>::type, continuation_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct query_static_constexpr_member :
|
||||
traits::query_static_constexpr_member<
|
||||
typename relationship_t<I>::template static_proxy<T>::type,
|
||||
continuation_t> {};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(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(continuation_t::static_query<E>())>
|
||||
static constexpr const T static_query_v
|
||||
= continuation_t::static_query<E>();
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
static constexpr relationship_t<I> value()
|
||||
{
|
||||
return continuation_t();
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const continuation_t&, const continuation_t&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const continuation_t&, const continuation_t&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const continuation_t&, const fork_t<I>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const continuation_t&, const fork_t<I>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
template <int I> template <typename E, typename T>
|
||||
const T continuation_t<I>::static_query_v;
|
||||
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace relationship
|
||||
} // namespace detail
|
||||
|
||||
typedef detail::relationship_t<> relationship_t;
|
||||
|
||||
ASIO_INLINE_VARIABLE constexpr relationship_t relationship;
|
||||
|
||||
} // namespace execution
|
||||
|
||||
#if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::relationship_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::relationship_t::fork_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_applicable_property<T, execution::relationship_t::continuation_t>
|
||||
: integral_constant<bool, execution::is_executor<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
template <typename T>
|
||||
struct query_free_default<T, execution::relationship_t,
|
||||
enable_if_t<
|
||||
can_query<T, execution::relationship_t::fork_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_query<T, execution::relationship_t::fork_t>::value;
|
||||
|
||||
typedef execution::relationship_t result_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct query_free_default<T, execution::relationship_t,
|
||||
enable_if_t<
|
||||
!can_query<T, execution::relationship_t::fork_t>::value
|
||||
&& can_query<T, execution::relationship_t::continuation_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept =
|
||||
is_nothrow_query<T, execution::relationship_t::continuation_t>::value;
|
||||
|
||||
typedef execution::relationship_t result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|
||||
|| !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t,
|
||||
enable_if_t<
|
||||
execution::detail::relationship_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::relationship_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::relationship_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t,
|
||||
enable_if_t<
|
||||
!execution::detail::relationship_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::relationship_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& traits::static_query<T,
|
||||
execution::relationship_t::fork_t>::is_valid
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef typename traits::static_query<T,
|
||||
execution::relationship_t::fork_t>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return traits::static_query<T,
|
||||
execution::relationship_t::fork_t>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t,
|
||||
enable_if_t<
|
||||
!execution::detail::relationship_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::relationship_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& !traits::static_query<T,
|
||||
execution::relationship_t::fork_t>::is_valid
|
||||
&& traits::static_query<T,
|
||||
execution::relationship_t::continuation_t>::is_valid
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef typename traits::static_query<T,
|
||||
execution::relationship_t::continuation_t>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return traits::static_query<T,
|
||||
execution::relationship_t::continuation_t>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t::fork_t,
|
||||
enable_if_t<
|
||||
execution::detail::relationship::fork_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::relationship::fork_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::relationship::fork_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t::fork_t,
|
||||
enable_if_t<
|
||||
!execution::detail::relationship::fork_t<0>::
|
||||
query_static_constexpr_member<T>::is_valid
|
||||
&& !execution::detail::relationship::fork_t<0>::
|
||||
query_member<T>::is_valid
|
||||
&& !traits::query_free<T,
|
||||
execution::relationship_t::fork_t>::is_valid
|
||||
&& !can_query<T, execution::relationship_t::continuation_t>::value
|
||||
>>
|
||||
{
|
||||
static constexpr bool is_valid = true;
|
||||
static constexpr bool is_noexcept = true;
|
||||
|
||||
typedef execution::relationship_t::fork_t result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct static_query<T, execution::relationship_t::continuation_t,
|
||||
enable_if_t<
|
||||
execution::detail::relationship::continuation_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::relationship::continuation_t<0>::
|
||||
query_static_constexpr_member<T>::result_type result_type;
|
||||
|
||||
static constexpr result_type value()
|
||||
{
|
||||
return execution::detail::relationship::continuation_t<0>::
|
||||
query_static_constexpr_member<T>::value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
|
||||
// || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_RELATIONSHIP_HPP
|
||||
Reference in New Issue
Block a user