Added
Link Here
|
1 |
From a707db8193b30b6cc4a3d10ee946f7f245e07097 Mon Sep 17 00:00:00 2001 |
2 |
From: Christopher Kohlhoff <chris@kohlhoff.com> |
3 |
Date: Tue, 7 Apr 2020 11:18:31 +1000 |
4 |
Subject: [PATCH] Support C++20 concept syntax. |
5 |
|
6 |
--- |
7 |
include/boost/asio/async_result.hpp | 18 +++++++++++------- |
8 |
include/boost/asio/detail/config.hpp | 10 +++++++--- |
9 |
2 files changed, 18 insertions(+), 10 deletions(-) |
10 |
|
11 |
diff --git a/include/boost/asio/async_result.hpp b/include/boost/asio/async_result.hpp |
12 |
index 2f4b337d1..0eea0f471 100644 |
13 |
--- boost/asio/async_result.hpp |
14 |
+++ boost/asio/async_result.hpp |
15 |
@@ -66,9 +66,10 @@ BOOST_ASIO_CONCEPT completion_signature = |
16 |
#define BOOST_ASIO_COMPLETION_SIGNATURE \ |
17 |
::boost::asio::completion_signature |
18 |
|
19 |
-template <typename T, completion_signature Signature> |
20 |
+template <typename T, typename Signature> |
21 |
BOOST_ASIO_CONCEPT completion_handler_for = |
22 |
- detail::is_completion_handler_for<T, Signature>::value; |
23 |
+ detail::is_completion_signature<Signature>::value |
24 |
+ && detail::is_completion_handler_for<T, Signature>::value; |
25 |
|
26 |
#define BOOST_ASIO_COMPLETION_HANDLER_FOR(s) \ |
27 |
::boost::asio::completion_handler_for<s> |
28 |
@@ -488,11 +489,14 @@ struct initiation_archetype |
29 |
|
30 |
} // namespace detail |
31 |
|
32 |
-template <typename T, completion_signature Signature> |
33 |
-BOOST_ASIO_CONCEPT completion_token_for = requires(T&& t) |
34 |
-{ |
35 |
- async_initiate<T, Signature>(detail::initiation_archetype<Signature>{}, t); |
36 |
-}; |
37 |
+template <typename T, typename Signature> |
38 |
+BOOST_ASIO_CONCEPT completion_token_for = |
39 |
+ detail::is_completion_signature<Signature>::value |
40 |
+ && |
41 |
+ requires(T&& t) |
42 |
+ { |
43 |
+ async_initiate<T, Signature>(detail::initiation_archetype<Signature>{}, t); |
44 |
+ }; |
45 |
|
46 |
#define BOOST_ASIO_COMPLETION_TOKEN_FOR(s) \ |
47 |
::boost::asio::completion_token_for<s> |
48 |
diff --git a/include/boost/asio/detail/config.hpp b/include/boost/asio/detail/config.hpp |
49 |
index 27d1d6753..6b85cccea 100644 |
50 |
--- boost/asio/detail/config.hpp |
51 |
+++ boost/asio/detail/config.hpp |
52 |
@@ -343,10 +343,14 @@ |
53 |
// Support concepts on compilers known to allow them. |
54 |
#if !defined(BOOST_ASIO_HAS_CONCEPTS) |
55 |
# if !defined(BOOST_ASIO_DISABLE_CONCEPTS) |
56 |
-# if __cpp_concepts |
57 |
+# if defined(__cpp_concepts) |
58 |
# define BOOST_ASIO_HAS_CONCEPTS 1 |
59 |
-# define BOOST_ASIO_CONCEPT concept bool |
60 |
-# endif // __cpp_concepts |
61 |
+# if (__cpp_concepts >= 201707) |
62 |
+# define BOOST_ASIO_CONCEPT concept |
63 |
+# else // (__cpp_concepts >= 201707) |
64 |
+# define BOOST_ASIO_CONCEPT concept bool |
65 |
+# endif // (__cpp_concepts >= 201707) |
66 |
+# endif // defined(__cpp_concepts) |
67 |
# endif // !defined(BOOST_ASIO_DISABLE_CONCEPTS) |
68 |
#endif // !defined(BOOST_ASIO_HAS_CONCEPTS) |
69 |
|