From 26714aceeede18feb19554de7f4d358835c6030d Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Thu, 28 Mar 2024 07:30:34 +0000 Subject: [PATCH] Specialize traits for `beast::test::immediate_executor` --- .../_experimental/test/immediate_executor.hpp | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/include/boost/beast/_experimental/test/immediate_executor.hpp b/include/boost/beast/_experimental/test/immediate_executor.hpp index cb469fcb..a5d23906 100644 --- a/include/boost/beast/_experimental/test/immediate_executor.hpp +++ b/include/boost/beast/_experimental/test/immediate_executor.hpp @@ -25,7 +25,7 @@ class immediate_executor public: immediate_executor(std::size_t & count) noexcept : count_(count) {} - asio::execution_context &query(asio::execution::context_t) const + asio::execution_context &query(asio::execution::context_t) const noexcept { BOOST_ASSERT(false); return *static_cast(nullptr); @@ -64,8 +64,52 @@ class immediate_executor } }; -} -} -} +} // test +} // beast + +namespace asio +{ +namespace traits +{ +template +struct execute_member +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + typedef void result_type; +}; + +template<> +struct equality_comparable +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +template<> +struct query_member +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef execution_context& result_type; +}; + +template +struct query_static_constexpr_member< + beast::test::immediate_executor, + Property, + typename enable_if::value>::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef execution::blocking_t::never_t result_type; + static constexpr result_type value() noexcept + { + return result_type(); + } +}; +} // traits +} // asio +} // boost #endif //BOOST_BEAST_TEST_IMMEDIATE_EXECUTOR_HPP