summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp')
-rw-r--r--3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp132
1 files changed, 65 insertions, 67 deletions
diff --git a/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp b/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp
index 331d8ac32ef..3c2b1308bd8 100644
--- a/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp
+++ b/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp
@@ -1,8 +1,8 @@
//
-// async_ops.hpp
-// ~~~~~~~~~~~~~
+// archetypes/async_ops.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 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)
@@ -11,30 +11,22 @@
#ifndef ARCHETYPES_ASYNC_OPS_HPP
#define ARCHETYPES_ASYNC_OPS_HPP
-#include <asio/associated_allocator.hpp>
-#include <asio/associated_executor.hpp>
-#include <asio/async_result.hpp>
-#include <asio/error.hpp>
-
-#if defined(ASIO_HAS_BOOST_BIND)
-# include <boost/bind.hpp>
-#else // defined(ASIO_HAS_BOOST_BIND)
-# include <functional>
-#endif // defined(ASIO_HAS_BOOST_BIND)
+#include <functional>
+#include "asio/associated_allocator.hpp"
+#include "asio/associated_executor.hpp"
+#include "asio/async_result.hpp"
+#include "asio/error.hpp"
namespace archetypes {
-#if defined(ASIO_HAS_BOOST_BIND)
-namespace bindns = boost;
-#else // defined(ASIO_HAS_BOOST_BIND)
namespace bindns = std;
-#endif // defined(ASIO_HAS_BOOST_BIND)
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void())
-async_op_0(ASIO_MOVE_ARG(CompletionToken) token)
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void()>::return_type
+async_op_0(CompletionToken&& token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void()>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -46,16 +38,17 @@ async_op_0(ASIO_MOVE_ARG(CompletionToken) token)
typename asio::associated_executor<handler_type>::type ex
= asio::get_associated_executor(completion.completion_handler);
- ex.post(ASIO_MOVE_CAST(handler_type)(completion.completion_handler), a);
+ ex.post(static_cast<handler_type&&>(completion.completion_handler), a);
return completion.result.get();
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(asio::error_code))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(asio::error_code)>::return_type
async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(asio::error_code)>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -71,14 +64,14 @@ async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code()), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(asio::error::operation_aborted)), a);
}
@@ -86,10 +79,11 @@ async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(std::exception_ptr)>::return_type
async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(std::exception_ptr)>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -105,14 +99,14 @@ async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::exception_ptr()), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::make_exception_ptr(std::runtime_error("blah"))), a);
}
@@ -120,10 +114,11 @@ async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(int)>::return_type
async_op_1(ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(int)>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -137,18 +132,18 @@ async_op_1(ASIO_MOVE_ARG(CompletionToken) token)
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
42), a);
return completion.result.get();
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken,
- void(asio::error_code, int))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(asio::error_code, int)>::return_type
async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(asio::error_code, int)>::completion_handler_type
handler_type;
@@ -165,14 +160,14 @@ async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(), 42), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(asio::error::operation_aborted),
0), a);
}
@@ -181,10 +176,11 @@ async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr, int))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(std::exception_ptr, int)>::return_type
async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(std::exception_ptr, int)>::completion_handler_type
handler_type;
@@ -201,14 +197,14 @@ async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::exception_ptr(), 42), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::make_exception_ptr(std::runtime_error("blah")), 0), a);
}
@@ -216,10 +212,11 @@ async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(int, double)>::return_type
async_op_2(ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(int, double)>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -233,18 +230,18 @@ async_op_2(ASIO_MOVE_ARG(CompletionToken) token)
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
42, 2.0), a);
return completion.result.get();
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken,
- void(asio::error_code, int, double))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(asio::error_code, int, double)>::return_type
async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(asio::error_code, int, double)>::completion_handler_type
handler_type;
@@ -261,14 +258,14 @@ async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(), 42, 2.0), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(asio::error::operation_aborted),
0, 0.0), a);
}
@@ -277,11 +274,11 @@ async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken,
- void(std::exception_ptr, int, double))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(std::exception_ptr, int, double)>::return_type
async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(std::exception_ptr, int, double)>::completion_handler_type
handler_type;
@@ -298,14 +295,14 @@ async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::exception_ptr(), 42, 2.0), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0), a);
}
@@ -313,10 +310,11 @@ async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double, char))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(int, double, char)>::return_type
async_op_3(ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(int, double, char)>::completion_handler_type handler_type;
asio::async_completion<CompletionToken,
@@ -330,18 +328,18 @@ async_op_3(ASIO_MOVE_ARG(CompletionToken) token)
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
42, 2.0, 'a'), a);
return completion.result.get();
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken,
- void(asio::error_code, int, double, char))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(asio::error_code, int, double, char)>::return_type
async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(asio::error_code, int, double, char)>::completion_handler_type
handler_type;
@@ -358,14 +356,14 @@ async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(), 42, 2.0, 'a'), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
asio::error_code(asio::error::operation_aborted),
0, 0.0, 'z'), a);
}
@@ -374,11 +372,11 @@ async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
}
template <typename CompletionToken>
-ASIO_INITFN_RESULT_TYPE(CompletionToken,
- void(std::exception_ptr, int, double, char))
+typename asio::async_result<asio::decay_t<CompletionToken>,
+ void(std::exception_ptr, int, double, char)>::return_type
async_op_ex_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
- typedef typename asio::async_completion<CompletionToken,
+ typedef typename asio::async_result<asio::decay_t<CompletionToken>,
void(std::exception_ptr, int, double, char)>::completion_handler_type
handler_type;
@@ -395,14 +393,14 @@ async_op_ex_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token)
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::exception_ptr(), 42, 2.0, 'a'), a);
}
else
{
ex.post(
bindns::bind(
- ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ static_cast<handler_type&&>(completion.completion_handler),
std::make_exception_ptr(std::runtime_error("blah")),
0, 0.0, 'z'), a);
}