diff --git a/include/boost/asio.hpp b/include/boost/asio.hpp index 4197bb40..3f0e153d 100644 --- a/include/boost/asio.hpp +++ b/include/boost/asio.hpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/asio/detail/type_traits.hpp b/include/boost/asio/detail/type_traits.hpp index 25dc82c4..7d3dab85 100644 --- a/include/boost/asio/detail/type_traits.hpp +++ b/include/boost/asio/detail/type_traits.hpp @@ -23,11 +23,15 @@ # include # include # include +# include +# include # include # include # include # include # include +# include +# include # include # include # include @@ -52,7 +56,11 @@ using std::is_base_of; using std::is_class; using std::is_const; using std::is_convertible; +using std::is_copy_constructible; +using std::is_destructible; using std::is_function; +using std::is_nothrow_copy_constructible; +using std::is_nothrow_destructible; using std::is_same; using std::remove_pointer; using std::remove_reference; @@ -77,7 +85,13 @@ using boost::is_base_of; using boost::is_class; using boost::is_const; using boost::is_convertible; +using boost::is_copy_constructible; +using boost::is_destructible; using boost::is_function; +template +struct is_nothrow_copy_constructible : boost::has_nothrow_copy {}; +template +struct is_nothrow_destructible : boost::has_nothrow_destructor {}; using boost::is_same; using boost::remove_pointer; using boost::remove_reference; diff --git a/include/boost/asio/execution/executor.hpp b/include/boost/asio/execution/executor.hpp new file mode 100644 index 00000000..f9842a21 --- /dev/null +++ b/include/boost/asio/execution/executor.hpp @@ -0,0 +1,92 @@ +// +// execution/executor.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 BOOST_ASIO_EXECUTION_EXECUTOR_HPP +#define BOOST_ASIO_EXECUTION_EXECUTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT) \ + && defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) \ + && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) +# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT 1 +#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT) + // && defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + // && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#include + +namespace boost { +namespace asio { +namespace execution { + +/// 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 +struct is_executor : +#if defined(GENERATING_DOCUMENTATION) + integral_constant +#else // defined(GENERATING_DOCUMENTATION) + integral_constant::value +#if defined(BOOST_ASIO_HAS_NOEXCEPT) + && is_nothrow_copy_constructible::value + && is_nothrow_destructible::value +#else // defined(BOOST_ASIO_HAS_NOEXCEPT) + && is_copy_constructible::value + && is_destructible::value +#endif // defined(BOOST_ASIO_HAS_NOEXCEPT) + && traits::equality_comparable::type>::is_valid + && traits::equality_comparable::type>::is_noexcept + > +#endif // defined(GENERATING_DOCUMENTATION) +{ +}; + +#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) + +template +BOOST_ASIO_CONSTEXPR const bool is_executor_v = is_executor::value; + +#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) + +#if defined(BOOST_ASIO_HAS_CONCEPTS) + +template +BOOST_ASIO_CONCEPT executor = is_executor::value; + +#define BOOST_ASIO_EXECUTION_EXECUTOR ::boost::asio::execution::executor + +#else // defined(BOOST_ASIO_HAS_CONCEPTS) + +#define BOOST_ASIO_EXECUTION_EXECUTOR typename + +#endif // defined(BOOST_ASIO_HAS_CONCEPTS) + +} // namespace execution +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_EXECUTION_EXECUTOR_HPP diff --git a/include/boost/asio/traits/equality_comparable.hpp b/include/boost/asio/traits/equality_comparable.hpp new file mode 100644 index 00000000..c49a21f0 --- /dev/null +++ b/include/boost/asio/traits/equality_comparable.hpp @@ -0,0 +1,102 @@ +// +// traits/equality_comparable.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 BOOST_ASIO_TRAITS_EQUALITY_COMPARABLE_HPP +#define BOOST_ASIO_TRAITS_EQUALITY_COMPARABLE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include +#include + +#if defined(BOOST_ASIO_HAS_DECLTYPE) \ + && defined(BOOST_ASIO_HAS_NOEXCEPT) \ + && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) +# define BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT 1 +#endif // defined(BOOST_ASIO_HAS_DECLTYPE) + // && defined(BOOST_ASIO_HAS_NOEXCEPT) + // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) + +namespace boost { +namespace asio { +namespace traits { + +template +struct equality_comparable_default; + +template +struct equality_comparable; + +} // namespace traits +namespace detail { + +struct no_equality_comparable +{ + BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false); + BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); +}; + +#if defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template +struct equality_comparable_trait : no_equality_comparable +{ +}; + +template +struct equality_comparable_trait(declval() == declval()), + static_cast(declval() != declval()) + ) + >::type> +{ + BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); + + BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = + noexcept(declval() == declval()) + && noexcept(declval() != declval())); +}; + +#else // defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template +struct equality_comparable_trait : + conditional< + is_same::type>::value, + no_equality_comparable, + traits::equality_comparable::type> + >::type +{ +}; + +#endif // defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace detail +namespace traits { + +template +struct equality_comparable_default : detail::equality_comparable_trait +{ +}; + +template +struct equality_comparable : equality_comparable_default +{ +}; + +} // namespace traits +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_TRAITS_EQUALITY_COMPARABLE_HPP