diff --git a/asio/include/asio/as_tuple.hpp b/asio/include/asio/as_tuple.hpp index 01042880d5..ab1894efce 100644 --- a/asio/include/asio/as_tuple.hpp +++ b/asio/include/asio/as_tuple.hpp @@ -141,7 +141,7 @@ struct partial_as_tuple * asynchronous operation's default completion token (or asio::deferred * if no default is available). */ -constexpr partial_as_tuple as_tuple; +ASIO_INLINE_VARIABLE constexpr partial_as_tuple as_tuple; } // namespace asio diff --git a/asio/include/asio/deferred.hpp b/asio/include/asio/deferred.hpp index c12a0e85f3..3e608addc3 100644 --- a/asio/include/asio/deferred.hpp +++ b/asio/include/asio/deferred.hpp @@ -708,7 +708,7 @@ inline auto operator|(Head head, Tail&& tail) /** * See the documentation for asio::deferred_t for a usage example. */ -constexpr deferred_t deferred; +ASIO_INLINE_VARIABLE constexpr deferred_t deferred; } // namespace asio diff --git a/asio/include/asio/detached.hpp b/asio/include/asio/detached.hpp index 070945570a..001d355460 100644 --- a/asio/include/asio/detached.hpp +++ b/asio/include/asio/detached.hpp @@ -94,7 +94,7 @@ class detached_t /** * See the documentation for asio::detached_t for a usage example. */ -constexpr detached_t detached; +ASIO_INLINE_VARIABLE constexpr detached_t detached; } // namespace asio diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index ec2654a963..61ee75249a 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -366,6 +366,19 @@ # endif // !defined(ASIO_DISABLE_VARIADIC_LAMBDA_CAPTURES) #endif // !defined(ASIO_HAS_VARIADIC_LAMBDA_CAPTURES) +// Support for inline variables. +#if !defined(ASIO_HAS_INLINE_VARIABLES) +# if !defined(ASIO_DISABLE_INLINE_VARIABLES) +# if (__cplusplus >= 201703) && (__cpp_inline_variables >= 201606) +# define ASIO_HAS_INLINE_VARIABLES 1 +# define ASIO_INLINE_VARIABLE inline +# endif // (__cplusplus >= 201703) && (__cpp_inline_variables >= 201606) +# endif // !defined(ASIO_DISABLE_INLINE_VARIABLES) +#endif // !defined(ASIO_HAS_INLINE_VARIABLES) +#if !defined(ASIO_INLINE_VARIABLE) +# define ASIO_INLINE_VARIABLE +#endif // !defined(ASIO_INLINE_VARIABLE) + // Default alignment. #if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) # define ASIO_DEFAULT_ALIGN __STDCPP_DEFAULT_NEW_ALIGNMENT__ diff --git a/asio/include/asio/execution/allocator.hpp b/asio/include/asio/execution/allocator.hpp index cdb6a4a920..30daf386f9 100644 --- a/asio/include/asio/execution/allocator.hpp +++ b/asio/include/asio/execution/allocator.hpp @@ -225,7 +225,7 @@ const T allocator_t::static_query_v; #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) -constexpr allocator_t allocator; +ASIO_INLINE_VARIABLE constexpr allocator_t allocator; } // namespace execution diff --git a/asio/include/asio/execution/blocking.hpp b/asio/include/asio/execution/blocking.hpp index e120299bde..41135e0745 100644 --- a/asio/include/asio/execution/blocking.hpp +++ b/asio/include/asio/execution/blocking.hpp @@ -892,7 +892,7 @@ const T never_t::static_query_v; typedef detail::blocking_t<> blocking_t; -constexpr blocking_t blocking; +ASIO_INLINE_VARIABLE constexpr blocking_t blocking; } // namespace execution diff --git a/asio/include/asio/execution/blocking_adaptation.hpp b/asio/include/asio/execution/blocking_adaptation.hpp index a2769b254a..412fbaa192 100644 --- a/asio/include/asio/execution/blocking_adaptation.hpp +++ b/asio/include/asio/execution/blocking_adaptation.hpp @@ -718,7 +718,7 @@ void blocking_execute( typedef detail::blocking_adaptation_t<> blocking_adaptation_t; -constexpr blocking_adaptation_t blocking_adaptation; +ASIO_INLINE_VARIABLE constexpr blocking_adaptation_t blocking_adaptation; } // namespace execution diff --git a/asio/include/asio/execution/context.hpp b/asio/include/asio/execution/context.hpp index a9df9c1c4b..f624f89e7f 100644 --- a/asio/include/asio/execution/context.hpp +++ b/asio/include/asio/execution/context.hpp @@ -138,7 +138,7 @@ const T context_t::static_query_v; typedef detail::context_t<> context_t; -constexpr context_t context; +ASIO_INLINE_VARIABLE constexpr context_t context; } // namespace execution diff --git a/asio/include/asio/execution/mapping.hpp b/asio/include/asio/execution/mapping.hpp index 4c6e179186..11563131f6 100644 --- a/asio/include/asio/execution/mapping.hpp +++ b/asio/include/asio/execution/mapping.hpp @@ -733,7 +733,7 @@ const T other_t::static_query_v; typedef detail::mapping_t<> mapping_t; -constexpr mapping_t mapping; +ASIO_INLINE_VARIABLE constexpr mapping_t mapping; } // namespace execution diff --git a/asio/include/asio/execution/occupancy.hpp b/asio/include/asio/execution/occupancy.hpp index c986c88113..57042ce6ff 100644 --- a/asio/include/asio/execution/occupancy.hpp +++ b/asio/include/asio/execution/occupancy.hpp @@ -131,7 +131,7 @@ const T occupancy_t::static_query_v; typedef detail::occupancy_t<> occupancy_t; -constexpr occupancy_t occupancy; +ASIO_INLINE_VARIABLE constexpr occupancy_t occupancy; } // namespace execution diff --git a/asio/include/asio/execution/outstanding_work.hpp b/asio/include/asio/execution/outstanding_work.hpp index 600792b95b..edcfd1403e 100644 --- a/asio/include/asio/execution/outstanding_work.hpp +++ b/asio/include/asio/execution/outstanding_work.hpp @@ -544,7 +544,7 @@ const T tracked_t::static_query_v; typedef detail::outstanding_work_t<> outstanding_work_t; -constexpr outstanding_work_t outstanding_work; +ASIO_INLINE_VARIABLE constexpr outstanding_work_t outstanding_work; } // namespace execution diff --git a/asio/include/asio/execution/relationship.hpp b/asio/include/asio/execution/relationship.hpp index e4f27555e2..e15660d14c 100644 --- a/asio/include/asio/execution/relationship.hpp +++ b/asio/include/asio/execution/relationship.hpp @@ -542,7 +542,7 @@ const T continuation_t::static_query_v; typedef detail::relationship_t<> relationship_t; -constexpr relationship_t relationship; +ASIO_INLINE_VARIABLE constexpr relationship_t relationship; } // namespace execution diff --git a/asio/include/asio/experimental/use_coro.hpp b/asio/include/asio/experimental/use_coro.hpp index 57bc382051..409bf4b2a9 100644 --- a/asio/include/asio/experimental/use_coro.hpp +++ b/asio/include/asio/experimental/use_coro.hpp @@ -173,9 +173,9 @@ struct use_coro_t * See the documentation for asio::use_coro_t for a usage example. */ #if defined(GENERATING_DOCUMENTATION) -constexpr use_coro_t<> use_coro; +ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro; #else -constexpr use_coro_t<> use_coro(0, 0, 0); +ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro(0, 0, 0); #endif } // namespace experimental diff --git a/asio/include/asio/experimental/use_promise.hpp b/asio/include/asio/experimental/use_promise.hpp index cf19aca59d..721b89de56 100644 --- a/asio/include/asio/experimental/use_promise.hpp +++ b/asio/include/asio/experimental/use_promise.hpp @@ -99,7 +99,7 @@ struct use_promise_t Allocator allocator_; }; -constexpr use_promise_t<> use_promise; +ASIO_INLINE_VARIABLE constexpr use_promise_t<> use_promise; } // namespace experimental } // namespace asio diff --git a/asio/include/asio/placeholders.hpp b/asio/include/asio/placeholders.hpp index 21da545fe9..328224defa 100644 --- a/asio/include/asio/placeholders.hpp +++ b/asio/include/asio/placeholders.hpp @@ -58,12 +58,18 @@ unspecified signal_number; #else -static constexpr auto& error = std::placeholders::_1; -static constexpr auto& bytes_transferred = std::placeholders::_2; -static constexpr auto& iterator = std::placeholders::_2; -static constexpr auto& results = std::placeholders::_2; -static constexpr auto& endpoint = std::placeholders::_2; -static constexpr auto& signal_number = std::placeholders::_2; +static ASIO_INLINE_VARIABLE constexpr auto& error + = std::placeholders::_1; +static ASIO_INLINE_VARIABLE constexpr auto& bytes_transferred + = std::placeholders::_2; +static ASIO_INLINE_VARIABLE constexpr auto& iterator + = std::placeholders::_2; +static ASIO_INLINE_VARIABLE constexpr auto& results + = std::placeholders::_2; +static ASIO_INLINE_VARIABLE constexpr auto& endpoint + = std::placeholders::_2; +static ASIO_INLINE_VARIABLE constexpr auto& signal_number + = std::placeholders::_2; #endif diff --git a/asio/include/asio/this_coro.hpp b/asio/include/asio/this_coro.hpp index 37381b92ab..ff347e75f4 100644 --- a/asio/include/asio/this_coro.hpp +++ b/asio/include/asio/this_coro.hpp @@ -32,7 +32,7 @@ struct executor_t }; /// Awaitable object that returns the executor of the current coroutine. -constexpr executor_t executor; +ASIO_INLINE_VARIABLE constexpr executor_t executor; /// Awaitable type that returns the cancellation state of the current coroutine. struct cancellation_state_t @@ -57,7 +57,7 @@ struct cancellation_state_t * // ... * } @endcode */ -constexpr cancellation_state_t cancellation_state; +ASIO_INLINE_VARIABLE constexpr cancellation_state_t cancellation_state; #if defined(GENERATING_DOCUMENTATION) diff --git a/asio/include/asio/use_awaitable.hpp b/asio/include/asio/use_awaitable.hpp index 6dd42f3d6e..a77596376a 100644 --- a/asio/include/asio/use_awaitable.hpp +++ b/asio/include/asio/use_awaitable.hpp @@ -145,9 +145,9 @@ struct use_awaitable_t * See the documentation for asio::use_awaitable_t for a usage example. */ #if defined(GENERATING_DOCUMENTATION) -constexpr use_awaitable_t<> use_awaitable; +ASIO_INLINE_VARIABLE constexpr use_awaitable_t<> use_awaitable; #else -constexpr use_awaitable_t<> use_awaitable(0, 0, 0); +ASIO_INLINE_VARIABLE constexpr use_awaitable_t<> use_awaitable(0, 0, 0); #endif } // namespace asio diff --git a/asio/include/asio/use_future.hpp b/asio/include/asio/use_future.hpp index 26f5ae1fed..9f136c7079 100644 --- a/asio/include/asio/use_future.hpp +++ b/asio/include/asio/use_future.hpp @@ -145,7 +145,7 @@ class use_future_t /** * See the documentation for asio::use_future_t for a usage example. */ -constexpr use_future_t<> use_future; +ASIO_INLINE_VARIABLE constexpr use_future_t<> use_future; } // namespace asio diff --git a/asio/include/asio/uses_executor.hpp b/asio/include/asio/uses_executor.hpp index ff475cad4a..a1c976ca83 100644 --- a/asio/include/asio/uses_executor.hpp +++ b/asio/include/asio/uses_executor.hpp @@ -45,7 +45,7 @@ struct executor_arg_t * See asio::executor_arg_t and asio::uses_executor * for more information. */ -constexpr executor_arg_t executor_arg; +ASIO_INLINE_VARIABLE constexpr executor_arg_t executor_arg; /// The uses_executor trait detects whether a type T has an associated executor /// that is convertible from type Executor. diff --git a/asio/src/doc/reference.dox b/asio/src/doc/reference.dox index d56207d34c..548f23c884 100644 --- a/asio/src/doc/reference.dox +++ b/asio/src/doc/reference.dox @@ -317,6 +317,7 @@ PREDEFINED = GENERATING_DOCUMENTATION \ ASIO_CONSTEXPR=constexpr \ ASIO_NOEXCEPT=noexcept \ ASIO_NODISCARD= \ + ASIO_INLINE_VARIABLE= \ ASIO_COMPLETION_SIGNATURE=typename \ ASIO_COMPLETION_HANDLER_FOR(s)=typename \ ASIO_COMPLETION_TOKEN_FOR(s)=typename \