]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spawn/test/test_async_result.cc
1 // Copyright (c) 2020 Casey Bodley (cbodley at redhat dot com)
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #include <spawn/spawn.hpp>
9 // make assertions about async_result::return_type with different signatures
10 // this is a compilation test only
12 template <typename Sig
>
13 struct yield_result
: boost::asio::async_result
<spawn::yield_context
, Sig
> {};
15 template <typename T
, typename Sig
>
16 struct yield_returns
: std::is_same
<T
, typename yield_result
<Sig
>::return_type
> {};
19 static_assert(yield_returns
<void, void()>::value
,
20 "wrong return value for void()");
21 static_assert(yield_returns
<void, void(boost::system::error_code
)>::value
,
22 "wrong return value for void(error_code)");
23 // single-parameter return value
24 static_assert(yield_returns
<int, void(int)>::value
,
25 "wrong return value for void(int)");
26 static_assert(yield_returns
<int, void(boost::system::error_code
, int)>::value
,
27 "wrong return value for void(error_code, int)");
28 // multiple-parameter return value
29 static_assert(yield_returns
<std::tuple
<int, std::string
>,
30 void(int, std::string
)>::value
,
31 "wrong return value for void(int, string)");
32 static_assert(yield_returns
<std::tuple
<int, std::string
>,
33 void(boost::system::error_code
, int, std::string
)>::value
,
34 "wrong return value for void(error_code, int, string)");
35 // single-tuple-parameter return value
36 static_assert(yield_returns
<std::tuple
<int, std::string
>,
37 void(std::tuple
<int, std::string
>)>::value
,
38 "wrong return value for void(std::tuple<int>)");
39 static_assert(yield_returns
<std::tuple
<int, std::string
>,
40 void(boost::system::error_code
, std::tuple
<int, std::string
>)>::value
,
41 "wrong return value for void(error_code, std::tuple<int>)");
42 // single-pair-parameter return value
43 static_assert(yield_returns
<std::pair
<int, std::string
>,
44 void(std::pair
<int, std::string
>)>::value
,
45 "wrong return value for void(std::tuple<int>)");
46 static_assert(yield_returns
<std::pair
<int, std::string
>,
47 void(boost::system::error_code
, std::pair
<int, std::string
>)>::value
,
48 "wrong return value for void(error_code, std::tuple<int>)");