diff options
Diffstat (limited to '3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp')
-rw-r--r-- | 3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp | 194 |
1 files changed, 98 insertions, 96 deletions
diff --git a/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp b/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp index d16650ae799..b6e77dd31a9 100644 --- a/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp +++ b/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp @@ -2,7 +2,7 @@ // blocking_adaptation.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -34,12 +34,12 @@ struct ex_nq_nr { } - friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) ASIO_NOEXCEPT + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept { return true; } - friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept { return false; } @@ -53,8 +53,8 @@ namespace traits { template <> struct equality_comparable<ex_nq_nr> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -64,8 +64,8 @@ struct equality_comparable<ex_nq_nr> template <typename Function> struct execute_member<ex_nq_nr, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -78,7 +78,7 @@ struct execute_member<ex_nq_nr, Function> template <typename ResultType, typename ParamType, typename Result> struct ex_cq_nr { - static ASIO_CONSTEXPR ResultType query(ParamType) ASIO_NOEXCEPT + static constexpr ResultType query(ParamType) noexcept { return Result(); } @@ -88,12 +88,12 @@ struct ex_cq_nr { } - friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) ASIO_NOEXCEPT + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept { return true; } - friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept { return false; } @@ -107,8 +107,8 @@ namespace traits { template <typename ResultType, typename ParamType, typename Result> struct equality_comparable<ex_cq_nr<ResultType, ParamType, Result> > { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -119,8 +119,8 @@ template <typename ResultType, typename ParamType, typename Result, typename Function> struct execute_member<ex_cq_nr<ResultType, ParamType, Result>, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -137,12 +137,12 @@ struct query_static_constexpr_member< asio::is_convertible<Param, ParamType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef Result result_type; // Must return raw result type. - static ASIO_CONSTEXPR result_type value() + static constexpr result_type value() { return Result(); } @@ -156,7 +156,7 @@ struct query_static_constexpr_member< template <typename ResultType, typename ParamType, typename Result> struct ex_mq_nr { - ResultType query(ParamType) const ASIO_NOEXCEPT + ResultType query(ParamType) const noexcept { return Result(); } @@ -166,12 +166,12 @@ struct ex_mq_nr { } - friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) ASIO_NOEXCEPT + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept { return true; } - friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept { return false; } @@ -185,8 +185,8 @@ namespace traits { template <typename ResultType, typename ParamType, typename Result> struct equality_comparable<ex_mq_nr<ResultType, ParamType, Result> > { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -197,8 +197,8 @@ template <typename ResultType, typename ParamType, typename Result, typename Function> struct execute_member<ex_mq_nr<ResultType, ParamType, Result>, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -215,8 +215,8 @@ struct query_member< asio::is_convertible<Param, ParamType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ResultType result_type; }; @@ -229,7 +229,7 @@ struct query_member< template <typename ResultType, typename ParamType, typename Result> struct ex_fq_nr { - friend ResultType query(const ex_fq_nr&, ParamType) ASIO_NOEXCEPT + friend ResultType query(const ex_fq_nr&, ParamType) noexcept { return Result(); } @@ -239,12 +239,12 @@ struct ex_fq_nr { } - friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) ASIO_NOEXCEPT + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept { return true; } - friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept { return false; } @@ -258,8 +258,8 @@ namespace traits { template <typename ResultType, typename ParamType, typename Result> struct equality_comparable<ex_fq_nr<ResultType, ParamType, Result> > { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -270,8 +270,8 @@ template <typename ResultType, typename ParamType, typename Result, typename Function> struct execute_member<ex_fq_nr<ResultType, ParamType, Result>, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -288,8 +288,8 @@ struct query_free< asio::is_convertible<Param, ParamType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ResultType result_type; }; @@ -302,24 +302,24 @@ struct query_free< template <typename CurrentType, typename OtherType> struct ex_mq_mr { - CurrentType query(CurrentType) const ASIO_NOEXCEPT + CurrentType query(CurrentType) const noexcept { return CurrentType(); } - CurrentType query(OtherType) const ASIO_NOEXCEPT + CurrentType query(OtherType) const noexcept { return CurrentType(); } ex_mq_mr<CurrentType, OtherType> require( - CurrentType) const ASIO_NOEXCEPT + CurrentType) const noexcept { return ex_mq_mr<CurrentType, OtherType>(); } ex_mq_mr<OtherType, CurrentType> require( - OtherType) const ASIO_NOEXCEPT + OtherType) const noexcept { return ex_mq_mr<OtherType, CurrentType>(); } @@ -329,12 +329,12 @@ struct ex_mq_mr { } - friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) ASIO_NOEXCEPT + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept { return true; } - friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept { return false; } @@ -343,13 +343,13 @@ struct ex_mq_mr template <typename CurrentType> struct ex_mq_mr<CurrentType, CurrentType> { - CurrentType query(CurrentType) const ASIO_NOEXCEPT + CurrentType query(CurrentType) const noexcept { return CurrentType(); } ex_mq_mr<CurrentType, CurrentType> require( - CurrentType) const ASIO_NOEXCEPT + CurrentType) const noexcept { return ex_mq_mr<CurrentType, CurrentType>(); } @@ -359,12 +359,12 @@ struct ex_mq_mr<CurrentType, CurrentType> { } - friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) ASIO_NOEXCEPT + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept { return true; } - friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept { return false; } @@ -378,8 +378,8 @@ namespace traits { template <typename CurrentType, typename OtherType> struct equality_comparable<ex_mq_mr<CurrentType, OtherType> > { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -389,8 +389,8 @@ struct equality_comparable<ex_mq_mr<CurrentType, OtherType> > template <typename CurrentType, typename OtherType, typename Function> struct execute_member<ex_mq_mr<CurrentType, OtherType>, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -407,8 +407,8 @@ struct query_member< || asio::is_convertible<Param, OtherType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef CurrentType result_type; }; @@ -424,8 +424,8 @@ struct require_member< asio::is_convertible<Param, CurrentType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_mq_mr<CurrentType, OtherType> result_type; }; @@ -438,8 +438,8 @@ struct require_member< && !asio::is_same<CurrentType, OtherType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_mq_mr<OtherType, CurrentType> result_type; }; @@ -452,36 +452,36 @@ struct require_member< template <typename CurrentType, typename OtherType> struct ex_fq_fr { - friend CurrentType query(const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept { return CurrentType(); } - friend CurrentType query(const ex_fq_fr&, OtherType) ASIO_NOEXCEPT + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept { return CurrentType(); } friend ex_fq_fr<CurrentType, OtherType> require( - const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + const ex_fq_fr&, CurrentType) noexcept { return ex_fq_fr<CurrentType, OtherType>(); } friend ex_fq_fr<OtherType, CurrentType> require( - const ex_fq_fr&, OtherType) ASIO_NOEXCEPT + const ex_fq_fr&, OtherType) noexcept { return ex_fq_fr<OtherType, CurrentType>(); } friend ex_fq_fr<CurrentType, OtherType> prefer( - const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + const ex_fq_fr&, CurrentType) noexcept { return ex_fq_fr<CurrentType, OtherType>(); } friend ex_fq_fr<OtherType, CurrentType> prefer( - const ex_fq_fr&, OtherType) ASIO_NOEXCEPT + const ex_fq_fr&, OtherType) noexcept { return ex_fq_fr<OtherType, CurrentType>(); } @@ -491,12 +491,12 @@ struct ex_fq_fr { } - friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) ASIO_NOEXCEPT + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept { return true; } - friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept { return false; } @@ -505,19 +505,19 @@ struct ex_fq_fr template <typename CurrentType> struct ex_fq_fr<CurrentType, CurrentType> { - friend CurrentType query(const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept { return CurrentType(); } friend ex_fq_fr<CurrentType, CurrentType> require( - const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + const ex_fq_fr&, CurrentType) noexcept { return ex_fq_fr<CurrentType, CurrentType>(); } friend ex_fq_fr<CurrentType, CurrentType> prefer( - const ex_fq_fr&, CurrentType) ASIO_NOEXCEPT + const ex_fq_fr&, CurrentType) noexcept { return ex_fq_fr<CurrentType, CurrentType>(); } @@ -527,12 +527,12 @@ struct ex_fq_fr<CurrentType, CurrentType> { } - friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) ASIO_NOEXCEPT + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept { return true; } - friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) ASIO_NOEXCEPT + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept { return false; } @@ -546,8 +546,8 @@ namespace traits { template <typename CurrentType, typename OtherType> struct equality_comparable<ex_fq_fr<CurrentType, OtherType> > { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) @@ -557,8 +557,8 @@ struct equality_comparable<ex_fq_fr<CurrentType, OtherType> > template <typename CurrentType, typename OtherType, typename Function> struct execute_member<ex_fq_fr<CurrentType, OtherType>, Function> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; typedef void result_type; }; @@ -575,8 +575,8 @@ struct query_free< || asio::is_convertible<Param, OtherType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef CurrentType result_type; }; @@ -592,8 +592,8 @@ struct require_free< asio::is_convertible<Param, CurrentType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_fq_fr<CurrentType, OtherType> result_type; }; @@ -606,8 +606,8 @@ struct require_free< && !asio::is_same<CurrentType, OtherType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_fq_fr<OtherType, CurrentType> result_type; }; @@ -623,8 +623,8 @@ struct prefer_free< asio::is_convertible<Param, CurrentType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_fq_fr<CurrentType, OtherType> result_type; }; @@ -637,8 +637,8 @@ struct prefer_free< && !asio::is_same<CurrentType, OtherType>::value >::type> { - ASIO_STATIC_CONSTEXPR(bool, is_valid = true); - ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; typedef ex_fq_fr<OtherType, CurrentType> result_type; }; @@ -651,19 +651,19 @@ struct prefer_free< template <typename Executor, typename Param, bool ExpectedResult> void test_can_query() { - ASIO_CONSTEXPR bool b1 = + constexpr bool b1 = asio::can_query<Executor, Param>::value; ASIO_CHECK(b1 == ExpectedResult); - ASIO_CONSTEXPR bool b2 = + constexpr bool b2 = asio::can_query<const Executor, Param>::value; ASIO_CHECK(b2 == ExpectedResult); - ASIO_CONSTEXPR bool b3 = + constexpr bool b3 = asio::can_query<Executor&, Param>::value; ASIO_CHECK(b3 == ExpectedResult); - ASIO_CONSTEXPR bool b4 = + constexpr bool b4 = asio::can_query<const Executor&, Param>::value; ASIO_CHECK(b4 == ExpectedResult); } @@ -686,29 +686,27 @@ void test_query() template <typename Executor, typename Param, typename ExpectedResult> void test_constexpr_query() { -#if defined(ASIO_HAS_CONSTEXPR) constexpr Executor ex1 = {}; constexpr exec::blocking_adaptation_t result1 = asio::query(ex1, Param()); ASIO_CHECK(result1 == ExpectedResult()); -#endif // defined(ASIO_HAS_CONSTEXPR) } template <typename Executor, typename Param, bool ExpectedResult> void test_can_require() { - ASIO_CONSTEXPR bool b1 = + constexpr bool b1 = asio::can_require<Executor, Param>::value; ASIO_CHECK(b1 == ExpectedResult); - ASIO_CONSTEXPR bool b2 = + constexpr bool b2 = asio::can_require<const Executor, Param>::value; ASIO_CHECK(b2 == ExpectedResult); - ASIO_CONSTEXPR bool b3 = + constexpr bool b3 = asio::can_require<Executor&, Param>::value; ASIO_CHECK(b3 == ExpectedResult); - ASIO_CONSTEXPR bool b4 = + constexpr bool b4 = asio::can_require<const Executor&, Param>::value; ASIO_CHECK(b4 == ExpectedResult); } @@ -757,19 +755,19 @@ void test_require() template <typename Executor, typename Param, bool ExpectedResult> void test_can_prefer() { - ASIO_CONSTEXPR bool b1 = + constexpr bool b1 = asio::can_prefer<Executor, Param>::value; ASIO_CHECK(b1 == ExpectedResult); - ASIO_CONSTEXPR bool b2 = + constexpr bool b2 = asio::can_prefer<const Executor, Param>::value; ASIO_CHECK(b2 == ExpectedResult); - ASIO_CONSTEXPR bool b3 = + constexpr bool b3 = asio::can_prefer<Executor&, Param>::value; ASIO_CHECK(b3 == ExpectedResult); - ASIO_CONSTEXPR bool b4 = + constexpr bool b4 = asio::can_prefer<const Executor&, Param>::value; ASIO_CHECK(b4 == ExpectedResult); } @@ -798,8 +796,12 @@ void test_prefer() void test_vars() { ASIO_CHECK(s() == exec::blocking_adaptation); + ASIO_CHECK(s() != exec::blocking_adaptation.disallowed); + ASIO_CHECK(s() != exec::blocking_adaptation.allowed); ASIO_CHECK(n1() == exec::blocking_adaptation.disallowed); + ASIO_CHECK(n1() != exec::blocking_adaptation.allowed); ASIO_CHECK(n2() == exec::blocking_adaptation.allowed); + ASIO_CHECK(n2() != exec::blocking_adaptation.disallowed); } ASIO_TEST_SUITE |