Skip to content

Commit efdc25a

Browse files
committed
Mark constexpr global variables as inline.
1 parent 30227a3 commit efdc25a

20 files changed

+46
-26
lines changed

asio/include/asio/as_tuple.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct partial_as_tuple
141141
* asynchronous operation's default completion token (or asio::deferred
142142
* if no default is available).
143143
*/
144-
constexpr partial_as_tuple as_tuple;
144+
ASIO_INLINE_VARIABLE constexpr partial_as_tuple as_tuple;
145145

146146
} // namespace asio
147147

asio/include/asio/deferred.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ inline auto operator|(Head head, Tail&& tail)
708708
/**
709709
* See the documentation for asio::deferred_t for a usage example.
710710
*/
711-
constexpr deferred_t deferred;
711+
ASIO_INLINE_VARIABLE constexpr deferred_t deferred;
712712

713713
} // namespace asio
714714

asio/include/asio/detached.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class detached_t
9494
/**
9595
* See the documentation for asio::detached_t for a usage example.
9696
*/
97-
constexpr detached_t detached;
97+
ASIO_INLINE_VARIABLE constexpr detached_t detached;
9898

9999
} // namespace asio
100100

asio/include/asio/detail/config.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,19 @@
366366
# endif // !defined(ASIO_DISABLE_VARIADIC_LAMBDA_CAPTURES)
367367
#endif // !defined(ASIO_HAS_VARIADIC_LAMBDA_CAPTURES)
368368

369+
// Support for inline variables.
370+
#if !defined(ASIO_HAS_INLINE_VARIABLES)
371+
# if !defined(ASIO_DISABLE_INLINE_VARIABLES)
372+
# if (__cplusplus >= 201703) && (__cpp_inline_variables >= 201606)
373+
# define ASIO_HAS_INLINE_VARIABLES 1
374+
# define ASIO_INLINE_VARIABLE inline
375+
# endif // (__cplusplus >= 201703) && (__cpp_inline_variables >= 201606)
376+
# endif // !defined(ASIO_DISABLE_INLINE_VARIABLES)
377+
#endif // !defined(ASIO_HAS_INLINE_VARIABLES)
378+
#if !defined(ASIO_INLINE_VARIABLE)
379+
# define ASIO_INLINE_VARIABLE
380+
#endif // !defined(ASIO_INLINE_VARIABLE)
381+
369382
// Default alignment.
370383
#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
371384
# define ASIO_DEFAULT_ALIGN __STDCPP_DEFAULT_NEW_ALIGNMENT__

asio/include/asio/execution/allocator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const T allocator_t<void>::static_query_v;
225225
#endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
226226
// && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
227227

228-
constexpr allocator_t<void> allocator;
228+
ASIO_INLINE_VARIABLE constexpr allocator_t<void> allocator;
229229

230230
} // namespace execution
231231

asio/include/asio/execution/blocking.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ const T never_t<I>::static_query_v;
892892

893893
typedef detail::blocking_t<> blocking_t;
894894

895-
constexpr blocking_t blocking;
895+
ASIO_INLINE_VARIABLE constexpr blocking_t blocking;
896896

897897
} // namespace execution
898898

asio/include/asio/execution/blocking_adaptation.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ void blocking_execute(
718718

719719
typedef detail::blocking_adaptation_t<> blocking_adaptation_t;
720720

721-
constexpr blocking_adaptation_t blocking_adaptation;
721+
ASIO_INLINE_VARIABLE constexpr blocking_adaptation_t blocking_adaptation;
722722

723723
} // namespace execution
724724

asio/include/asio/execution/context.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const T context_t<I>::static_query_v;
138138

139139
typedef detail::context_t<> context_t;
140140

141-
constexpr context_t context;
141+
ASIO_INLINE_VARIABLE constexpr context_t context;
142142

143143
} // namespace execution
144144

asio/include/asio/execution/mapping.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ const T other_t<I>::static_query_v;
733733

734734
typedef detail::mapping_t<> mapping_t;
735735

736-
constexpr mapping_t mapping;
736+
ASIO_INLINE_VARIABLE constexpr mapping_t mapping;
737737

738738
} // namespace execution
739739

asio/include/asio/execution/occupancy.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const T occupancy_t<I>::static_query_v;
131131

132132
typedef detail::occupancy_t<> occupancy_t;
133133

134-
constexpr occupancy_t occupancy;
134+
ASIO_INLINE_VARIABLE constexpr occupancy_t occupancy;
135135

136136
} // namespace execution
137137

asio/include/asio/execution/outstanding_work.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ const T tracked_t<I>::static_query_v;
544544

545545
typedef detail::outstanding_work_t<> outstanding_work_t;
546546

547-
constexpr outstanding_work_t outstanding_work;
547+
ASIO_INLINE_VARIABLE constexpr outstanding_work_t outstanding_work;
548548

549549
} // namespace execution
550550

asio/include/asio/execution/relationship.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ const T continuation_t<I>::static_query_v;
542542

543543
typedef detail::relationship_t<> relationship_t;
544544

545-
constexpr relationship_t relationship;
545+
ASIO_INLINE_VARIABLE constexpr relationship_t relationship;
546546

547547
} // namespace execution
548548

asio/include/asio/experimental/use_coro.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ struct use_coro_t
173173
* See the documentation for asio::use_coro_t for a usage example.
174174
*/
175175
#if defined(GENERATING_DOCUMENTATION)
176-
constexpr use_coro_t<> use_coro;
176+
ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro;
177177
#else
178-
constexpr use_coro_t<> use_coro(0, 0, 0);
178+
ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro(0, 0, 0);
179179
#endif
180180

181181
} // namespace experimental

asio/include/asio/experimental/use_promise.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct use_promise_t
9999
Allocator allocator_;
100100
};
101101

102-
constexpr use_promise_t<> use_promise;
102+
ASIO_INLINE_VARIABLE constexpr use_promise_t<> use_promise;
103103

104104
} // namespace experimental
105105
} // namespace asio

asio/include/asio/placeholders.hpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ unspecified signal_number;
5858

5959
#else
6060

61-
static constexpr auto& error = std::placeholders::_1;
62-
static constexpr auto& bytes_transferred = std::placeholders::_2;
63-
static constexpr auto& iterator = std::placeholders::_2;
64-
static constexpr auto& results = std::placeholders::_2;
65-
static constexpr auto& endpoint = std::placeholders::_2;
66-
static constexpr auto& signal_number = std::placeholders::_2;
61+
static ASIO_INLINE_VARIABLE constexpr auto& error
62+
= std::placeholders::_1;
63+
static ASIO_INLINE_VARIABLE constexpr auto& bytes_transferred
64+
= std::placeholders::_2;
65+
static ASIO_INLINE_VARIABLE constexpr auto& iterator
66+
= std::placeholders::_2;
67+
static ASIO_INLINE_VARIABLE constexpr auto& results
68+
= std::placeholders::_2;
69+
static ASIO_INLINE_VARIABLE constexpr auto& endpoint
70+
= std::placeholders::_2;
71+
static ASIO_INLINE_VARIABLE constexpr auto& signal_number
72+
= std::placeholders::_2;
6773

6874
#endif
6975

asio/include/asio/this_coro.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct executor_t
3232
};
3333

3434
/// Awaitable object that returns the executor of the current coroutine.
35-
constexpr executor_t executor;
35+
ASIO_INLINE_VARIABLE constexpr executor_t executor;
3636

3737
/// Awaitable type that returns the cancellation state of the current coroutine.
3838
struct cancellation_state_t
@@ -57,7 +57,7 @@ struct cancellation_state_t
5757
* // ...
5858
* } @endcode
5959
*/
60-
constexpr cancellation_state_t cancellation_state;
60+
ASIO_INLINE_VARIABLE constexpr cancellation_state_t cancellation_state;
6161

6262
#if defined(GENERATING_DOCUMENTATION)
6363

asio/include/asio/use_awaitable.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ struct use_awaitable_t
145145
* See the documentation for asio::use_awaitable_t for a usage example.
146146
*/
147147
#if defined(GENERATING_DOCUMENTATION)
148-
constexpr use_awaitable_t<> use_awaitable;
148+
ASIO_INLINE_VARIABLE constexpr use_awaitable_t<> use_awaitable;
149149
#else
150-
constexpr use_awaitable_t<> use_awaitable(0, 0, 0);
150+
ASIO_INLINE_VARIABLE constexpr use_awaitable_t<> use_awaitable(0, 0, 0);
151151
#endif
152152

153153
} // namespace asio

asio/include/asio/use_future.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class use_future_t
145145
/**
146146
* See the documentation for asio::use_future_t for a usage example.
147147
*/
148-
constexpr use_future_t<> use_future;
148+
ASIO_INLINE_VARIABLE constexpr use_future_t<> use_future;
149149

150150
} // namespace asio
151151

asio/include/asio/uses_executor.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct executor_arg_t
4545
* See asio::executor_arg_t and asio::uses_executor
4646
* for more information.
4747
*/
48-
constexpr executor_arg_t executor_arg;
48+
ASIO_INLINE_VARIABLE constexpr executor_arg_t executor_arg;
4949

5050
/// The uses_executor trait detects whether a type T has an associated executor
5151
/// that is convertible from type Executor.

asio/src/doc/reference.dox

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ PREDEFINED = GENERATING_DOCUMENTATION \
317317
ASIO_CONSTEXPR=constexpr \
318318
ASIO_NOEXCEPT=noexcept \
319319
ASIO_NODISCARD= \
320+
ASIO_INLINE_VARIABLE= \
320321
ASIO_COMPLETION_SIGNATURE=typename \
321322
ASIO_COMPLETION_HANDLER_FOR(s)=typename \
322323
ASIO_COMPLETION_TOKEN_FOR(s)=typename \

0 commit comments

Comments
 (0)