Add execution::receiver concepts and traits.
This change adds the concepts: * execution::receiver * execution::receiver_of and the trait: * execution::is_nothrow_receiver_of It also adds the following traits that correspond to the concepts: * execution::is_receiver * execution::is_receiver_of
This commit is contained in:
parent
dffb5d3e0b
commit
afff66d73e
@ -310,6 +310,7 @@ nobase_include_HEADERS = \
|
||||
asio/execution/occupancy.hpp \
|
||||
asio/execution/outstanding_work.hpp \
|
||||
asio/execution/prefer_only.hpp \
|
||||
asio/execution/receiver.hpp \
|
||||
asio/execution/relationship.hpp \
|
||||
asio/execution/set_done.hpp \
|
||||
asio/execution/set_error.hpp \
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "asio/execution/occupancy.hpp"
|
||||
#include "asio/execution/outstanding_work.hpp"
|
||||
#include "asio/execution/prefer_only.hpp"
|
||||
#include "asio/execution/receiver.hpp"
|
||||
#include "asio/execution/relationship.hpp"
|
||||
#include "asio/execution/set_done.hpp"
|
||||
#include "asio/execution/set_error.hpp"
|
||||
|
@ -32,10 +32,12 @@
|
||||
# include <boost/type_traits/is_class.hpp>
|
||||
# include <boost/type_traits/is_const.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
# include <boost/type_traits/is_constructible.hpp>
|
||||
# include <boost/type_traits/is_copy_constructible.hpp>
|
||||
# include <boost/type_traits/is_destructible.hpp>
|
||||
# include <boost/type_traits/is_function.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# include <boost/type_traits/remove_cv.hpp>
|
||||
# include <boost/type_traits/remove_pointer.hpp>
|
||||
# include <boost/type_traits/remove_reference.hpp>
|
||||
# include <boost/utility/declval.hpp>
|
||||
@ -58,15 +60,20 @@ using std::integral_constant;
|
||||
using std::is_base_of;
|
||||
using std::is_class;
|
||||
using std::is_const;
|
||||
using std::is_constructible;
|
||||
using std::is_convertible;
|
||||
using std::is_copy_constructible;
|
||||
using std::is_destructible;
|
||||
using std::is_function;
|
||||
using std::is_move_constructible;
|
||||
using std::is_nothrow_copy_constructible;
|
||||
using std::is_nothrow_destructible;
|
||||
using std::is_reference;
|
||||
using std::is_same;
|
||||
using std::is_scalar;
|
||||
using std::remove_cv;
|
||||
template <typename T>
|
||||
struct remove_cvref : remove_cv<typename std::remove_reference<T>::type> {};
|
||||
using std::remove_pointer;
|
||||
using std::remove_reference;
|
||||
#if defined(ASIO_HAS_STD_INVOKE_RESULT)
|
||||
@ -91,10 +98,18 @@ using boost::integral_constant;
|
||||
using boost::is_base_of;
|
||||
using boost::is_class;
|
||||
using boost::is_const;
|
||||
using boost::is_constructible;
|
||||
using boost::is_convertible;
|
||||
using boost::is_copy_constructible;
|
||||
using boost::is_destructible;
|
||||
using boost::is_function;
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
template <typename T>
|
||||
struct is_move_constructible : false_type {};
|
||||
#else // defined(ASIO_HAS_MOVE)
|
||||
template <typename T>
|
||||
struct is_move_constructible : is_copy_constructible<T> {};
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
template <typename T>
|
||||
struct is_nothrow_copy_constructible : boost::has_nothrow_copy<T> {};
|
||||
template <typename T>
|
||||
@ -102,6 +117,9 @@ struct is_nothrow_destructible : boost::has_nothrow_destructor<T> {};
|
||||
using boost::is_reference;
|
||||
using boost::is_same;
|
||||
using boost::is_scalar;
|
||||
using boost::remove_cv;
|
||||
template <typename T>
|
||||
struct remove_cvref : remove_cv<typename boost::remove_reference<T>::type> {};
|
||||
using boost::remove_pointer;
|
||||
using boost::remove_reference;
|
||||
using boost::result_of;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "asio/execution/occupancy.hpp"
|
||||
#include "asio/execution/outstanding_work.hpp"
|
||||
#include "asio/execution/prefer_only.hpp"
|
||||
#include "asio/execution/receiver.hpp"
|
||||
#include "asio/execution/relationship.hpp"
|
||||
#include "asio/execution/set_done.hpp"
|
||||
#include "asio/execution/set_error.hpp"
|
||||
|
261
asio/include/asio/execution/receiver.hpp
Normal file
261
asio/include/asio/execution/receiver.hpp
Normal file
@ -0,0 +1,261 @@
|
||||
//
|
||||
// execution/receiver.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2020 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_RECEIVER_HPP
|
||||
#define ASIO_EXECUTION_RECEIVER_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/variadic_templates.hpp"
|
||||
#include "asio/execution/set_done.hpp"
|
||||
#include "asio/execution/set_error.hpp"
|
||||
#include "asio/execution/set_value.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
# include <exception>
|
||||
#else // defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
# include "asio/error_code.hpp"
|
||||
#endif // defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
|
||||
#if defined(ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT) \
|
||||
&& defined(ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT)
|
||||
# define ASIO_HAS_DEDUCED_EXECUTION_IS_RECEIVER_TRAIT 1
|
||||
#endif // defined(ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT)
|
||||
// && defined(ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace execution {
|
||||
|
||||
#if defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
# define ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT = std::exception_ptr
|
||||
#else // defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
# define ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT \
|
||||
= ::asio::error_code
|
||||
#endif // defined(ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
|
||||
/// The is_receiver trait detects whether a type T satisfies the
|
||||
/// execution::receiver concept.
|
||||
/**
|
||||
* Class template @c is_receiver is a type trait that is derived from @c
|
||||
* true_type if the type @c T meets the concept definition for a receiver for
|
||||
* error type @c E, otherwise @c false_type.
|
||||
*/
|
||||
template <typename T, typename E ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
|
||||
struct is_receiver :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool, automatically_determined>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool,
|
||||
is_move_constructible<typename remove_cvref<T>::type>::value
|
||||
&& is_constructible<typename remove_cvref<T>::type, T>::value
|
||||
&& can_set_done<typename remove_cvref<T>::type>::value
|
||||
&& is_nothrow_set_done<typename remove_cvref<T>::type>::value
|
||||
&& can_set_error<typename remove_cvref<T>::type, E>::value
|
||||
&& is_nothrow_set_error<typename remove_cvref<T>::type, E>::value
|
||||
>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename E ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
|
||||
ASIO_CONSTEXPR const bool is_receiver_v = is_receiver<T, E>::value;
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
template <typename T, typename E ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
|
||||
ASIO_CONCEPT receiver = is_receiver<T, E>::value;
|
||||
|
||||
#define ASIO_EXECUTION_RECEIVER ::asio::execution::receiver
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_EXECUTION_RECEIVER typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#if defined(ASIO_HAS_VARIADIC_TEMPLATES) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The is_receiver_of trait detects whether a type T satisfies the
|
||||
/// execution::receiver_of concept for some set of value arguments.
|
||||
/**
|
||||
* Class template @c is_receiver_of is a type trait that is derived from @c
|
||||
* true_type if the type @c T meets the concept definition for a receiver for
|
||||
* value arguments @c Vs, otherwise @c false_type.
|
||||
*/
|
||||
template <typename T, typename... Vs>
|
||||
struct is_receiver_of :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool, automatically_determined>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool,
|
||||
is_receiver<T>::value
|
||||
&& can_set_value<typename remove_cvref<T>::type, Vs...>::value
|
||||
>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename... Vs>
|
||||
ASIO_CONSTEXPR const bool is_receiver_of_v =
|
||||
is_receiver_of<T, Vs...>::value;
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
template <typename T, typename... Vs>
|
||||
ASIO_CONCEPT receiver_of = is_receiver_of<T, Vs...>::value;
|
||||
|
||||
#define ASIO_EXECUTION_RECEIVER_OF_0 \
|
||||
::asio::execution::receiver_of
|
||||
|
||||
#define ASIO_EXECUTION_RECEIVER_OF_1(v) \
|
||||
::asio::execution::receiver_of<v>
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_EXECUTION_RECEIVER_OF_0 typename
|
||||
#define ASIO_EXECUTION_RECEIVER_OF_1(v) typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename T, typename = void,
|
||||
typename = void, typename = void, typename = void, typename = void,
|
||||
typename = void, typename = void, typename = void, typename = void>
|
||||
struct is_receiver_of;
|
||||
|
||||
template <typename T>
|
||||
struct is_receiver_of<T> :
|
||||
integral_constant<bool,
|
||||
is_receiver<T>::value
|
||||
&& can_set_value<typename remove_cvref<T>::type>::value
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
#define ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF(n) \
|
||||
template <typename T, ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct is_receiver_of<T, ASIO_VARIADIC_TARGS(n)> : \
|
||||
integral_constant<bool, \
|
||||
is_receiver<T>::value \
|
||||
&& can_set_value<typename remove_cvref<T>::type, \
|
||||
ASIO_VARIADIC_TARGS(n)>::value \
|
||||
> \
|
||||
{ \
|
||||
}; \
|
||||
/**/
|
||||
ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF)
|
||||
#undef ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(ASIO_HAS_VARIADIC_TEMPLATES) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The is_nothrow_receiver_of trait detects whether a type T satisfies the
|
||||
/// execution::receiver_of concept for some set of value arguments, with a
|
||||
/// noexcept @c set_value operation.
|
||||
/**
|
||||
* Class template @c is_nothrow_receiver_of is a type trait that is derived
|
||||
* from @c true_type if the type @c T meets the concept definition for a
|
||||
* receiver for value arguments @c Vs, and the expression
|
||||
* <tt>execution::set_value(declval<T>(), declval<Ts>()...)</tt> is noexcept,
|
||||
* otherwise @c false_type.
|
||||
*/
|
||||
template <typename T, typename... Vs>
|
||||
struct is_nothrow_receiver_of :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool, automatically_determined>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
integral_constant<bool,
|
||||
is_receiver_of<T, Vs...>::value
|
||||
&& is_nothrow_set_value<typename remove_cvref<T>::type, Vs...>::value
|
||||
>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
template <typename T, typename... Vs>
|
||||
ASIO_CONSTEXPR const bool is_nothrow_receiver_of_v =
|
||||
is_nothrow_receiver_of<T, Vs...>::value;
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
|
||||
|
||||
#else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename T, typename = void,
|
||||
typename = void, typename = void, typename = void, typename = void,
|
||||
typename = void, typename = void, typename = void, typename = void>
|
||||
struct is_nothrow_receiver_of;
|
||||
|
||||
template <typename T>
|
||||
struct is_nothrow_receiver_of<T> :
|
||||
integral_constant<bool,
|
||||
is_receiver_of<T>::value
|
||||
&& is_nothrow_set_value<typename remove_cvref<T>::type>::value
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
#define ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF(n) \
|
||||
template <typename T, ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct is_nothrow_receiver_of<T, ASIO_VARIADIC_TARGS(n)> : \
|
||||
integral_constant<bool, \
|
||||
is_receiver_of<T, ASIO_VARIADIC_TARGS(n)>::value \
|
||||
&& is_nothrow_set_value<typename remove_cvref<T>::type, \
|
||||
ASIO_VARIADIC_TARGS(n)>::value \
|
||||
> \
|
||||
{ \
|
||||
}; \
|
||||
/**/
|
||||
ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF)
|
||||
#undef ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF
|
||||
|
||||
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace execution
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_EXECUTION_RECEIVER_HPP
|
@ -157,6 +157,7 @@ UNIT_TEST_EXES = \
|
||||
tests\unit\execution\mapping.exe \
|
||||
tests\unit\execution\outstanding_work.exe \
|
||||
tests\unit\execution\prefer_only.exe \
|
||||
tests\unit\execution\receiver.exe \
|
||||
tests\unit\execution\relationship.exe \
|
||||
tests\unit\execution\set_done.exe \
|
||||
tests\unit\execution\set_error.exe \
|
||||
|
@ -53,6 +53,7 @@ check_PROGRAMS = \
|
||||
unit/execution/mapping \
|
||||
unit/execution/outstanding_work \
|
||||
unit/execution/prefer_only \
|
||||
unit/execution/receiver \
|
||||
unit/execution/relationship \
|
||||
unit/execution/set_done \
|
||||
unit/execution/set_error \
|
||||
@ -209,6 +210,7 @@ TESTS = \
|
||||
unit/execution/mapping \
|
||||
unit/execution/outstanding_work \
|
||||
unit/execution/prefer_only \
|
||||
unit/execution/receiver \
|
||||
unit/execution/relationship \
|
||||
unit/execution/set_done \
|
||||
unit/execution/set_error \
|
||||
@ -365,6 +367,7 @@ unit_execution_invocable_archetype_SOURCES = unit/execution/invocable_archetype.
|
||||
unit_execution_mapping_SOURCES = unit/execution/mapping.cpp
|
||||
unit_execution_outstanding_work_SOURCES = unit/execution/outstanding_work.cpp
|
||||
unit_execution_prefer_only_SOURCES = unit/execution/prefer_only.cpp
|
||||
unit_execution_receiver_SOURCES = unit/execution/receiver.cpp
|
||||
unit_execution_relationship_SOURCES = unit/execution/relationship.cpp
|
||||
unit_execution_set_done_SOURCES = unit/execution/set_done.cpp
|
||||
unit_execution_set_error_SOURCES = unit/execution/set_error.cpp
|
||||
|
1
asio/src/tests/unit/execution/.gitignore
vendored
1
asio/src/tests/unit/execution/.gitignore
vendored
@ -17,6 +17,7 @@ invocable_archetype
|
||||
mapping
|
||||
outstanding_work
|
||||
prefer_only
|
||||
receiver
|
||||
relationship
|
||||
set_done
|
||||
set_error
|
||||
|
521
asio/src/tests/unit/execution/receiver.cpp
Normal file
521
asio/src/tests/unit/execution/receiver.cpp
Normal file
@ -0,0 +1,521 @@
|
||||
//
|
||||
// receiver.cpp
|
||||
// ~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2020 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)
|
||||
//
|
||||
|
||||
// Disable autolinking for unit tests.
|
||||
#if !defined(BOOST_ALL_NO_LIB)
|
||||
#define BOOST_ALL_NO_LIB 1
|
||||
#endif // !defined(BOOST_ALL_NO_LIB)
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/execution/receiver.hpp"
|
||||
|
||||
#include <string>
|
||||
#include "asio/error_code.hpp"
|
||||
#include "../unit_test.hpp"
|
||||
|
||||
struct not_a_receiver
|
||||
{
|
||||
};
|
||||
|
||||
struct receiver
|
||||
{
|
||||
receiver()
|
||||
{
|
||||
}
|
||||
|
||||
receiver(const receiver&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receiver(receiver&&)
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
template <typename E>
|
||||
void set_error(ASIO_MOVE_ARG(E) e) ASIO_NOEXCEPT
|
||||
{
|
||||
(void)e;
|
||||
}
|
||||
|
||||
void set_done() ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace asio {
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
|
||||
template <typename E>
|
||||
struct set_error_member<receiver, E>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_done_member<receiver>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
} // namespace asio
|
||||
|
||||
struct receiver_of_0
|
||||
{
|
||||
receiver_of_0()
|
||||
{
|
||||
}
|
||||
|
||||
receiver_of_0(const receiver_of_0&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receiver_of_0(receiver_of_0&&)
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
template <typename E>
|
||||
void set_error(ASIO_MOVE_ARG(E) e) ASIO_NOEXCEPT
|
||||
{
|
||||
(void)e;
|
||||
}
|
||||
|
||||
void set_done() ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
void set_value()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace asio {
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
|
||||
template <typename E>
|
||||
struct set_error_member<receiver_of_0, E>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_done_member<receiver_of_0>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_value_member<receiver_of_0, void()>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
} // namespace asio
|
||||
|
||||
struct receiver_of_1
|
||||
{
|
||||
receiver_of_1()
|
||||
{
|
||||
}
|
||||
|
||||
receiver_of_1(const receiver_of_1&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receiver_of_1(receiver_of_1&&)
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
template <typename E>
|
||||
void set_error(ASIO_MOVE_ARG(E) e) ASIO_NOEXCEPT
|
||||
{
|
||||
(void)e;
|
||||
}
|
||||
|
||||
void set_done() ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
void set_value(int) ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace asio {
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
|
||||
template <typename E>
|
||||
struct set_error_member<receiver_of_1, E>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_done_member<receiver_of_1>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_value_member<receiver_of_1, void(int)>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
} // namespace asio
|
||||
|
||||
struct receiver_of_2
|
||||
{
|
||||
receiver_of_2()
|
||||
{
|
||||
}
|
||||
|
||||
receiver_of_2(const receiver_of_2&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receiver_of_2(receiver_of_2&&)
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
template <typename E>
|
||||
void set_error(ASIO_MOVE_ARG(E) e) ASIO_NOEXCEPT
|
||||
{
|
||||
(void)e;
|
||||
}
|
||||
|
||||
void set_done() ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
void set_value(int, std::string)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace asio {
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
|
||||
template <typename E>
|
||||
struct set_error_member<receiver_of_2, E>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_done_member<receiver_of_2>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
#if !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
template <>
|
||||
struct set_value_member<receiver_of_2, void(int, std::string)>
|
||||
{
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
|
||||
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
} // namespace asio
|
||||
|
||||
void is_receiver_test()
|
||||
{
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver<
|
||||
not_a_receiver,
|
||||
asio::error_code
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver<
|
||||
receiver,
|
||||
asio::error_code
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver<
|
||||
receiver_of_0,
|
||||
asio::error_code
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver<
|
||||
receiver_of_1,
|
||||
asio::error_code
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver<
|
||||
receiver_of_2,
|
||||
asio::error_code
|
||||
>::value));
|
||||
}
|
||||
|
||||
void is_receiver_of_test()
|
||||
{
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
not_a_receiver
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
not_a_receiver,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
not_a_receiver,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver_of<
|
||||
receiver_of_0
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_0,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_0,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_1
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver_of<
|
||||
receiver_of_1,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_1,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_2
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_receiver_of<
|
||||
receiver_of_2,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_receiver_of<
|
||||
receiver_of_2,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
}
|
||||
|
||||
void is_nothrow_receiver_of_test()
|
||||
{
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
not_a_receiver
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
not_a_receiver,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
not_a_receiver,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_0
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_0,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_0,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_1
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_1,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_1,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_2
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_2,
|
||||
int
|
||||
>::value));
|
||||
|
||||
ASIO_CHECK((
|
||||
!asio::execution::is_nothrow_receiver_of<
|
||||
receiver_of_2,
|
||||
int,
|
||||
std::string
|
||||
>::value));
|
||||
}
|
||||
|
||||
ASIO_TEST_SUITE
|
||||
(
|
||||
"receiver",
|
||||
ASIO_TEST_CASE(is_receiver_test)
|
||||
ASIO_TEST_CASE(is_receiver_of_test)
|
||||
ASIO_TEST_CASE(is_nothrow_receiver_of_test)
|
||||
)
|
Loading…
Reference in New Issue
Block a user