BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_compilerfeatures.h
Go to the documentation of this file.
1/// @file bsls_compilerfeatures.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_compilerfeatures.h -*-C++-*-
8#ifndef INCLUDED_BSLS_COMPILERFEATURES
9#define INCLUDED_BSLS_COMPILERFEATURES
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_compilerfeatures bsls_compilerfeatures
15/// @brief Provide macros to identify compiler support for C++11 features.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_compilerfeatures
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_compilerfeatures-purpose"> Purpose</a>
25/// * <a href="#bsls_compilerfeatures-macros"> Macros </a>
26/// * <a href="#bsls_compilerfeatures-description"> Description </a>
27/// * <a href="#bsls_compilerfeatures-special-formatting-rules-and-allowances"> Special Formatting Rules and Allowances </a>
28/// * <a href="#bsls_compilerfeatures-binary-macros"> Binary Macros </a>
29/// * <a href="#bsls_compilerfeatures-macro-summary"> Macro Summary </a>
30/// * <a href="#bsls_compilerfeatures-usage"> Usage </a>
31/// * <a href="#bsls_compilerfeatures-example-1-using-bsls_compilerfeatures_support_extern_template"> Example 1: Using BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE </a>
32/// * <a href="#bsls_compilerfeatures-example-2-__line__-macro-multi-line-value-differences-demonstration"> Example 2: __LINE__ Macro Multi-line Value Differences Demonstration </a>
33/// * <a href="#bsls_compilerfeatures-bugs-in-compilers"> Bugs in Compilers </a>
34/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_initializer_list_leaks_on_exceptions"> BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS </a>
35/// * <a href="#bsls_compilerfeatures-feature-support-in-compilers"> Feature Support in Compilers </a>
36/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_pp_line_is_on_first"> BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST </a>
37/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_alias_templates"> BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES </a>
38/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_alignas"> BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS </a>
39/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_noreturn"> BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN </a>
40/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_nodiscard"> BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD </a>
41/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_fallthrough"> BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH </a>
42/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_maybe_unused"> BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED </a>
43/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_concepts"> BSLS_COMPILERFEATURES_SUPPORT_CONCEPTS </a>
44/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr"> BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR </a>
45/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr_cpp14"> BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14 </a>
46/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr_cpp17"> BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17 </a>
47/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_coroutine"> BSLS_COMPILERFEATURES_SUPPORT_COROUTINE </a>
48/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_decltype"> BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE </a>
49/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_default_template_args"> BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS </a>
50/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_defaulted_functions"> BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS </a>
51/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_deleted_functions"> BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS </a>
52/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_extern_template"> BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE </a>
53/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_final"> BSLS_COMPILERFEATURES_SUPPORT_FINAL </a>
54/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_generalized_initializers"> BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS </a>
55/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_has_include"> BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE </a>
56/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_include_next"> BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT </a>
57/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_inline_namespace"> BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE </a>
58/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_inline_variables"> BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES </a>
59/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_noexcept"> BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT </a>
60/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_nullptr"> BSLS_COMPILERFEATURES_SUPPORT_NULLPTR </a>
61/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_operator_explicit"> BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT </a>
62/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_override"> BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE </a>
63/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_raw_strings"> BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS </a>
64/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_ref_qualifiers"> BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS </a>
65/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_rvalue_references"> BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES </a>
66/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_static_assert"> BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT </a>
67/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_three_way_comparison"> BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON </a>
68/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_variadic_templates"> BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES </a>
69/// * <a href="#bsls_compilerfeatures-bsls_compilerfeatures_support_variable_templates"> BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES </a>
70/// * <a href="#bsls_compilerfeatures-microsoft-visual-studio-versions-mapping"> Microsoft Visual Studio versions mapping </a>
71///
72/// # Purpose {#bsls_compilerfeatures-purpose}
73/// Provide macros to identify compiler support for C++11 features.
74///
75/// # Macros {#bsls_compilerfeatures-macros}
76///
77/// - BSLS_COMPILERFEATURES_CPLUSPLUS: portable version of `__cplusplus`
78/// - BSLS_COMPILERFEATURES_FORWARD_REF(T): argument of type `T` to be forwarded
79/// - BSLS_COMPILERFEATURES_FORWARD(T, V): forward argument `V` of type `T`
80/// - BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION: flag for return optimization
81/// - BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS: compiler bug
82/// - BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST: `__LINE__` value for multi-line
83/// - BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES: flag for alias templates
84/// - BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS: flag for `alignas`
85/// - BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH: `[[fallthrough]]`
86/// - BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED: `[[maybe_unused]]`
87/// - BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD: `[[nodiscard]]`
88/// - BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN: `[[noreturn]]` attribute
89/// - BSLS_COMPILERFEATURES_SUPPORT_CONCEPTS: C++20 core language concepts
90/// - BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR: `constexpr` specifier
91/// - BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14: C++14 `constexpr` spec.
92/// - BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17: C++17 `constexpr` spec.
93/// - BSLS_COMPILERFEATURES_SUPPORT_COROUTINE: core & lib C++20 coroutine support
94/// - BSLS_COMPILERFEATURES_SUPPORT_CTAD: flag for template argument deduction
95/// - BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE: flag for `decltype`
96/// - BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS: for function templates
97/// - BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS: explicit `= default`
98/// - BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS: explicit `= deleted`
99/// - BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS: flag for `enum class`
100/// - BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE: flag for `extern template`
101/// - BSLS_COMPILERFEATURES_SUPPORT_FINAL: flag for `final` keyword
102/// - BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS: init.-list syntax
103/// - BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE: flag for `__has_include`
104/// - BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS: `0x1.5p+5` supported
105/// - BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT: flag for @ref include_next
106/// - BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE: flag for `inline namespace`
107/// - BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES: flag for `inline` variables
108/// - BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT: `noexcept` operator
109/// - BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE: `noexcept` fnctype diff
110/// - BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_TYPES: deprecated, see above
111/// - BSLS_COMPILERFEATURES_SUPPORT_NULLPTR: flag for `nullptr`
112/// - BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT: `explicit` operator
113/// - BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE: `override` keyword
114/// - BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS: C++11-style R"tag(string)tag"
115/// - BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS: ref-qualified member function
116/// - BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES: flag for rvalue references
117/// - BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT: flag for @ref static_assert
118/// - BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON: `<=>` operator
119/// - BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS: C++98 exception specs.
120/// - BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER: has `<type_traits>` header
121/// - BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES: flag for `char(16|32)_t`
122/// - BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS: user-defined literals
123/// - BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE: flag for `char8_t`
124/// - BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES: variable templates flag
125/// - BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES: flag for variadic params.
126///
127/// @see bsls_libraryfeatures, bsls_platform
128///
129/// # Description {#bsls_compilerfeatures-description}
130/// This component provides a suite of preprocessor macros to
131/// identify compiler-specific support of language features that may not be
132/// available on all compilers in use across an organization. For example, as
133/// post-classic (C++11 and beyond) language facilities become more broadly
134/// available with sufficient quality (such as `extern template`) macros will be
135/// defined here to indicate whether the current platform/compiler combination
136/// supports the corresponding language features. Note that in some cases,
137/// support for a given feature may need to be explicitly enabled by using an
138/// appropriate compiler command-line option.
139///
140/// ## Special Formatting Rules and Allowances {#bsls_compilerfeatures-special-formatting-rules-and-allowances}
141///
142///
143/// This header is a large and complex mesh of fairly unrelated and deep
144/// preprocessor conditionals with defining and undefining of many features
145/// macros. It is hard for a human to scan this file and understand how and
146/// where particular feature macros are set. To make matter more difficult in
147/// certain circumstances we also unset/undefine macros. For this reason this
148/// header file uses a few special formatting rules to allow faster scanning:
149///
150/// 1. Only comments and the `1` (replacement text) of {Binary Macros} may be 79
151/// characters long (plus newline). Line continuation characters in long
152/// preprocessor conditionals etc. must be placed onto column 78. This is to
153/// allow a human to easily scan the file for places where feature macros are
154/// being defined.
155/// 2. Feature macro definitions that are commented out (to indicate that for a
156/// given compiler + standard library combination the support does not exist)
157/// must not have the replacement text (the number 1) be present so as not to
158/// confuse a human reader not using syntax highlighting.
159/// 3. Due to the depth of necessary conditional branches (`#if*`) and the
160/// unusually long feature macro names defined in this header we use 2 spaces
161/// indentation to ensure that most preprocessor directives don't wrap (and
162/// become hard to read).
163///
164/// ## Binary Macros {#bsls_compilerfeatures-binary-macros}
165///
166///
167/// Binary macros defined in this file (such as the
168/// `BSLS_COMPILERFEATURES_SUPPORT_*` macros, and the
169/// `BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS`, and the
170/// `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST` macros) that represents a
171/// true/false preprocessor value are either undefined or defined to be the
172/// integer value 1. This allows the traditional, idiomatic use of these macros
173/// where more brief preprocessor conditions rely on the fact that the C and C++
174/// preprocessors replace these unknown tokens with the value 0 in conditions:
175/// The following short condition
176/// @code
177/// #if BSLS_COMPILERFEATURES_SUPPORT_CTAD && /
178/// BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
179/// #define U_TAKE_MY_FINAL_FORM 1
180/// #endif
181/// @endcode
182/// works identical to the following, longer one.
183/// @code
184/// #if defined(BSLS_COMPILERFEATURES_SUPPORT_CTAD) && /
185/// defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
186/// #define U_TAKE_MY_FINAL_FORM 1
187/// #endif
188/// @endcode
189/// Note that the line continuation backslash has been replaced with `/` to
190/// silence "multiline comment" warnings.
191///
192/// ## Macro Summary {#bsls_compilerfeatures-macro-summary}
193///
194///
195/// The following are the macros provided by this component. Note that they are
196/// not defined for all platform/compiler combinations.
197///
198/// * `BSLS_COMPILERFEATURES_CPLUSPLUS`
199/// > This macro provides a portable way to determine the version of the C++
200/// > standard mode that is being used. In general, this has the same value
201/// > as the standard `__cplusplus` macro, but on some compilers with some
202/// > settings the standard macro does not get assigned the correct value.
203/// > The values generally set (as defined in the C++ Standard) are the year
204/// > and month when the Standard was completed, and the value of this macro
205/// > should be compared with the appropriate constants:
206/// > - 199711L -- before C++11
207/// > - 201103L -- C++11
208/// > - 201402L -- C++14
209/// > - 201703L -- C++17
210/// > - 202002L -- C++20
211/// > - 202302L -- C++23
212/// > Note that compilers may report "in-between" values to indicate partial
213/// > support of a standard, so `BSLS_COMPILERFEATURES_CPLUSPLUS > 201402L`
214/// > normally means that *some* C++17 features are available. Since those
215/// > values are not standardized their meaning varies.
216///
217/// * `BSLS_COMPILERFEATURES_FORWARD_REF(T)`
218/// > This macro provides a portable way to declare a function template
219/// > argument of type `T` that is to be perfect-forwarded. The expansion of
220/// > the macro will use syntax that is appropriate for the current compiler
221/// > settings for this platform.
222///
223/// * `BSLS_COMPILERFEATURES_FORWARD(T, V)`
224/// > This macro provides a portable way to perfect-forward a function
225/// > template argument, `V`, of type `T`. The expansion of the macro will
226/// > use syntax that is appropriate for the current compiler settings for
227/// > this platform. Note that due to the vagaries of implementing this
228/// > macro, client code using this macro should provide the following two
229/// > inclusions (in addition to the requisite inclusion of this header):
230/// > - `#include <bslmf_util.h>`
231/// > - `#include <bsls_util.h>`
232///
233/// * `BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION`
234/// > This macro is defined if the compiler always elides all copies (or
235/// > moves) when returning a prvalue expression from a function and using
236/// > that expression to initialize a class object of the same type
237/// > (ignoring cv qualifications). Specifically, given the function,
238/// > `Thing funcReturningThing() { return Thing(ctor-args...); }`, the
239/// > return value is always initialized with `(ctor-args...)`; no copy is
240/// > performed in the return statement. Additionally,
241/// > `Thing var(funcReturningThing())` always constructs `var` directly
242/// > from the return expression of `funcReturningThing()`; again, no copies
243/// > are involved. The semantics of these optimizations are guaranteed in
244/// > C++17 and later, but are optional in previous versions of C++.
245///
246/// * `BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS`
247/// > The `BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS` macro
248/// > is defined for implementations that leak temporary objects constructed
249/// > trying to initialize a `std::initializer_list` object in the event that
250/// > one of the elements of the list throws from its constructor. This is
251/// > known to affect gcc as recently as the 8.x series, and the Sun CC
252/// > compiler in C++11 mode. This would often reveal itself as a spurious
253/// > memory leak in exception-safety tests for @ref initializer_list
254/// > constructors, so rises to the level of a generally supported
255/// > defect-detection macro.
256///
257/// * `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST`
258/// > The `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST` macro is defined for
259/// > implementations that implement WG14 N2322
260/// > (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2322.htm)
261/// > "Recommended practice" on the substitution value for the `__LINE__`
262/// > (predefined) preprocessor macro when expanding a macro that uses
263/// > `__LINE__` in its body, and that macro invocation spans multiple source
264/// > lines (logical or physical). When macro is defined `__LINE__` is
265/// > substituted with the line number of the first character of the macro
266/// > name of the (multi-line) macro invocation. When this macro is not
267/// > defined `__LINE__` is replaced (as traditional on older C++ compilers)
268/// > by the line number of the last character of the macro invocation that
269/// > expands to a use of `__LINE__`. See also {Example 2: `__LINE__` Macro
270/// > Multi-line Value Differences Demonstration}.
271///
272/// * `BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES`
273/// > This macro is defined if alias templates are supported by the current
274/// > compiler settings for this platform.
275///
276/// * `BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS`
277/// > This macro is defined if `alignas` alignment specifier is supported by
278/// > the current compiler settings for this platform.
279///
280/// * `BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH`
281/// > This macro is defined if the `[[fallthrough]]` attribute is supported
282/// > by the current compiler settings for this platform.
283///
284/// * `BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED`
285/// > This macro is defined if the `[[maybe_unused]]` attribute is supported
286/// > by the current compiler settings for this platform.
287///
288/// * `BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD`
289/// > This macro is defined if the `[[nodiscard]]` attribute is supported by
290/// > the current compiler settings for this platform.
291///
292/// * `BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN`
293/// > This macro is defined if the `[[noreturn]]` attribute is supported by
294/// > the current compiler settings for this platform.
295///
296/// * `BSLS_COMPILERFEATURES_SUPPORT_CONCEPTS`
297/// > This macro is defined if the concepts core language feature is
298/// > supported by the current compiler settings for this platform, as
299/// > defined by ISO C++20.
300///
301/// * `BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR`
302/// > This macro is defined if `constexpr` is supported by the current
303/// > compiler settings for this platform.
304///
305/// * `BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14`
306/// > This macro is defined if `constexpr` with C++14 semantics is supported
307/// > by the current compiler settings for this platform. In particular,
308/// > this allows multiple statements in a `constexpr` function; changing
309/// > state of local variables within the function; and making non-`const`
310/// > member functions `constexpr`.
311///
312/// * `BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17`
313/// > This macro is defined if `constexpr` with C++17 semantics is supported
314/// > by the current compiler settings for this platform. In particular,
315/// > this allows lambda functions to be defined in a `constexpr` function.
316///
317/// * `BSLS_COMPILERFEATURES_SUPPORT_COROUTINE`
318/// > This macro is defined if coroutines with C++20 (or later) semantics are
319/// > supported by the current compiler settings, including the existence of
320/// > the <coroutine> standard header that provides the basic library
321/// > facilities necessary to make use of coroutines.
322///
323/// * `BSLS_COMPILERFEATURES_SUPPORT_CTAD`
324/// > This macro is defined if template argument deduction introduced in the
325/// > C++17 Standard are supported by the current compiler settings for this
326/// > platform.
327///
328/// * `BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE`
329/// > This macro is defined if `decltype` is supported by the current
330/// > compiler settings for this platform.
331///
332/// * `BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS`
333/// > This macro is defined if default template arguments for function
334/// > templates are supported by the current compiler settings for this
335/// > platform.
336///
337/// * `BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS`
338/// > This macro is defined if defaulted functions are supported by the
339/// > current compiler settings for this platform (i.e., via the `= default`
340/// > syntax).
341///
342/// * `BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS`
343/// > This macro is defined if deleted functions are supported by the
344/// > current compiler settings for this platform (i.e., via the `= delete`
345/// > syntax).
346///
347/// * `BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS`
348/// > This macro is defined if `enum class` is supported by the current
349/// > compiler settings for this platform.
350///
351/// * `BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE`
352/// > This macro is defined if `extern template` is supported by the current
353/// > compiler settings for this platform.
354///
355/// * `BSLS_COMPILERFEATURES_SUPPORT_FINAL`
356/// > This macro is defined if `final` is supported for classes and member
357/// > functions by the current compiler settings for this platform.
358///
359/// * `BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS`
360/// > This macro is defined if generalized initializers are supported by the
361/// > current compiler settings for this platform.
362///
363/// * `BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE`
364/// > This macro is defined if `__has_include` is supported by the current
365/// > compiler settings for this platform.
366///
367/// * `BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS`
368/// > This macro is defined if hexadecimal format literals for floating point
369/// > types are supported by the current compiler settings for this platform.
370///
371/// * `BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT`
372/// > This macro is defined if @ref include_next is supported by the current
373/// > compiler settings for this platform.
374///
375/// * `BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE`
376/// > This macro is defined if `inline` namespaces introduced in the C++11
377/// > Standard are supported by the current compiler settings for this
378/// > platform.
379///
380/// * `BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES`
381/// > This macro is defined if `inline` variables introduced in the C++17
382/// > Standard are supported by the current compiler settings for this
383/// > platform.
384///
385/// * `BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT`
386/// > This macro is defined if the `noexcept` keyword is supported by the
387/// > current compiler settings for this platform, both for designating a
388/// > function as not throwing and for testing if an expression may throw.
389/// > The definition of this macro does not depend on whether the current
390/// > compiler configuration has disabled support for exceptions.
391///
392/// * `BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE`
393/// > This macro is defined if the `noexcept` keyword is supported by the
394/// > current compiler settings for this platform such that if `noexcept` is
395/// > used to designate a function as not throwing, that use of `noexcept` is
396/// > explicitly considered part of the type of the function (a feature
397/// > introduced in C++17). The definition of this macro does not depend on
398/// > whether the current compiler configuration has disabled support for
399/// > exceptions.
400///
401/// * `BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_TYPES`
402/// > Deprecated, use `BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE`
403/// > instead.
404///
405/// * `BSLS_COMPILERFEATURES_SUPPORT_NULLPTR`
406/// > This macro is defined if `nullptr` is supported by the current compiler
407/// > settings for this platform.
408///
409/// * `BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT`
410/// > This macro is defined if the `explicit` keyword applied to conversion
411/// > operators is supported by the current compiler settings for this
412/// > platform.
413///
414/// * `BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE`
415/// > This macro is defined if the `override` keyword is supported by the
416/// > current compiler settings for this platform.
417///
418/// * `BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS`
419/// > This macro is defined if the compiler supports C++-11-style
420/// > R"tag(string)tag" strings.
421///
422/// * `BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS`
423/// > This macro is defined if member functions with trailing reference
424/// > qualifiers (e.g., `void myfunc(int) &&`) are supported by the current
425/// > compiler settings for this platform.
426///
427/// * `BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES`
428/// > This macro is defined if rvalue references are supported by the current
429/// > compiler settings for this platform.
430///
431/// * `BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT`
432/// > This macro is defined if @ref static_assert is supported by the current
433/// > compiler settings for this platform.
434///
435/// * `BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON`
436/// > This macro is defined if `<=>` operator is supported by the current
437/// > compiler settings for this platform. Including full library support as
438/// > of C++20.
439///
440/// * `BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS`
441/// > This macro is defined if dynamic exception specifications are supported
442/// > by the current compiler settings for this platform. Dynamic exception
443/// > specifications were deprecated in C++11, and actively removed from the
444/// > language in C++17. The definition of this macro does not depend on
445/// > whether the current compiler configuration has disabled support for
446/// > exceptions.
447///
448/// * `BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER`
449/// > This macro is defined if the standard library for the current compiler
450/// > settings for this platform supports some form of the standard
451/// > `<type_traits>` header. Note that many standard library
452/// > implementations provided partial support for a long time, and those
453/// > libraries *will* be identified as providing the `<type_traits>` header.
454///
455/// * `BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES`
456/// > This macro is defined if the compiler supports the `char16_t` and
457/// > `char32_t` types and the related u and U prefixes for character- and
458/// > string-literal values.
459///
460/// * `BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS`
461/// > This macro is defined if user-defined literals are supported by the
462/// > current compiler settings for this platform.
463///
464/// * `BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE`
465/// > This macro is defined if the compiler supports the `char8_t` type.
466///
467/// * `BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES`
468/// > This macro is defined if variadic template parameters are supported by
469/// > the current compiler settings for this platform.
470///
471/// * `BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES`
472/// > This macro is defined if variable templates introduced in the C++14
473/// > Standard are supported by the current compiler settings for this
474/// > platform.
475///
476/// ## Usage {#bsls_compilerfeatures-usage}
477///
478///
479/// The following code snippets illustrate use of this component.
480///
481/// ### Example 1: Using BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE {#bsls_compilerfeatures-example-1-using-bsls_compilerfeatures_support_extern_template}
482///
483///
484/// Suppose that we wish to "preinstantiate" `bsl::basic_string` for a given
485/// character type, say, `char`, on platforms that support `extern template`.
486/// To accomplish this, we would do the following in the `.h` and `.cpp` files
487/// of the @ref bslstl_string component:
488/// @code
489/// // bslstl_string.h
490/// // ...
491/// #ifdef BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE
492/// extern template class bsl::String_Imp<char, bsl::string::size_type>;
493/// extern template class bsl::basic_string<char>;
494/// #endif
495/// // ...
496///
497/// // bslstl_string.cpp
498/// // ...
499/// #ifdef BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE
500/// template class bsl::String_Imp<char, bsl::string::size_type>;
501/// template class bsl::basic_string<char>;
502/// #endif
503/// // ...
504/// @endcode
505///
506/// ### Example 2: __LINE__ Macro Multi-line Value Differences Demonstration {#bsls_compilerfeatures-example-2-__line__-macro-multi-line-value-differences-demonstration}
507///
508///
509/// Note that this isn't an example of use, it is a demonstration of compiler
510/// preprocessor behavior and the `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST`
511/// macro.
512///
513/// Sometimes we write code that uses line numbers for logging or other
514/// purposes. Although most of the time the precise values of those line
515/// numbers (in program output, such as assertions, or logs) is unimportant
516/// (the output is read by humans who are good at finding the line that
517/// actually emitted the text), sometimes programs read other programs' output.
518/// In such cases the precise values for the line numbers may matter. This
519/// example demonstrates the two ways our currently supported C++ compilers
520/// generate line numbers in multi-line macro expansion contexts (from the
521/// `__LINE__` macro), and how the presence (or absence) of the macro
522/// `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST` indicates which method the
523/// current compiler uses. First, we define a macro that uses `__LINE__` in its
524/// replacement text:
525/// @code
526/// #define THATS_MY_LINE(dummy) __LINE__
527/// @endcode
528/// Note that this macro has the function-like syntax so we can easily span its
529/// invocation to multiple lines.
530///
531/// Next, we record the current line number in a constant, and also record the
532/// line number from our macro, but we span the macro invocation multiple lines
533/// to invoke the unspecified behavior.
534///
535/// The two lines must follow each other due to working with line numbering:
536/// @code
537/// const long A_LINE = __LINE__;
538/// const long LINE_FROM_MACRO = THATS_MY_LINE
539/// (
540/// "dummy"
541/// )
542/// . ;
543/// @endcode
544/// We deliberately extended the macro invocation to more than 2 physical source
545/// code lines so that we can demonstrate the two distinct behaviors: using the
546/// line number of the first character or the last. Extending the number of
547/// lines *beyond* the macro invocation (by placing the semicolon on its own
548/// line) has no effect on the line number substitution inside the macro. The
549/// dummy argument is required for C++03 compatibility.
550///
551/// If we follow the definition of `A_LINE` without any intervening empty lines
552/// the line number of the first character of the macro invocation will be
553/// `A_LINE + 1`, while the last falls on line `A_LINE + 4`.
554///
555/// Now we demonstrate the two different behaviors and how the presence of
556/// `BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST` indicates which one will occur:
557/// @code
558/// #ifdef BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST
559/// assert(A_LINE + 1 == LINE_FROM_MACRO);
560/// #else
561/// assert(A_LINE + 4 == LINE_FROM_MACRO);
562/// #endif
563/// @endcode
564/// Finally note that WG14 N2322 defines this behavior as *unspecified*,
565/// therefore it is in the realm of possibilities, although not likely (in C++
566/// compilers) that further, more complicated or even indeterminate behaviors
567/// may arise.
568///
569/// ## Bugs in Compilers {#bsls_compilerfeatures-bugs-in-compilers}
570///
571///
572///
573/// ### BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS {#bsls_compilerfeatures-bsls_compilerfeatures_initializer_list_leaks_on_exceptions}
574///
575///
576/// This macro is defined if the compiler leaks temporary objects constructed
577/// trying to initialize a `std::initializer_list` object in the event that one
578/// of the elements of the list throws from its constructor.
579///
580/// * Compilers affected:
581/// - GCC
582/// - Oracle CC 12.6
583///
584/// ## Feature Support in Compilers {#bsls_compilerfeatures-feature-support-in-compilers}
585///
586///
587///
588/// Note that https://en.cppreference.com/w/cpp/compiler_support is a useful
589/// reference for initial versions to test for support for various features.
590///
591/// ### BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST {#bsls_compilerfeatures-bsls_compilerfeatures_pp_line_is_on_first}
592///
593///
594/// This macro is defined if the compiler substitutes the `__LINE__` macro in
595/// macro expansions with the line number of the first character of the macro
596/// invocation, which is the recommended practice for the C preprocessor (see
597/// WG14 N2322 at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2322.htm).
598/// Note that all BDE supported compilers that do not define this macro use the
599/// line number of the last character of the macro invocation instead.
600///
601/// * Compilers that implement N2322 Recommended practice:
602/// - GCC 9.0 and later
603///
604/// ### BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES {#bsls_compilerfeatures-bsls_compilerfeatures_support_alias_templates}
605///
606///
607/// This macro is defined if the compiler supports syntax to introduce a
608/// `typedef`-name using alias-declaration syntax, declaring a name for a family
609/// of types.
610///
611/// * Compiler support:
612/// - GCC 4.7
613/// - Clang 3.0
614/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
615/// - Oracle CC 12.4
616///
617/// ### BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS {#bsls_compilerfeatures-bsls_compilerfeatures_support_alignas}
618///
619///
620/// This macro is defined if the compiler supports the `alignas` alignment
621/// specifier.
622///
623/// * Compiler support:
624/// - GCC 4.8
625/// - Clang 3.0
626///
627/// This feature is not yet supported in Visual Studio, IBM xlC, Oracle CC.
628///
629/// ### BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN {#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_noreturn}
630///
631///
632/// This macro is defined if the compiler supports `[[noreturn]]` C++11
633/// attribute syntax. MSVC supports the attribute with alternative syntax
634/// __declspec(noreturn), earlier versions of GCC and Clang support the
635/// alternative syntax `__attribute__((noreturn))`, and xlC supports the
636/// alternative syntax `_Noreturn`. This macro does not support alternative
637/// syntaxes.
638///
639/// * Compiler support:
640/// - GCC 4.8
641/// - Clang 3.3
642/// - Oracle CC 12.4
643///
644/// ### BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD {#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_nodiscard}
645///
646///
647/// This macro is defined if the compiler supports `[[nodiscard]]` C++17
648/// attribute syntax.
649///
650/// * Compiler support:
651/// - Visual Studio 2017 version 15.3 (<u>MSC</u>VER 1911)
652///
653/// ### BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH {#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_fallthrough}
654///
655///
656/// This macro is defined if the compiler supports `[[fallthrough]]` C++17
657/// attribute syntax.
658///
659/// * Compiler support:
660/// - GCC 7.3
661/// - Clang 3.3
662/// - Visual Studio 2017 version 15.0 (<u>MSC</u>VER 1910)
663///
664/// ### BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED {#bsls_compilerfeatures-bsls_compilerfeatures_support_attribute_maybe_unused}
665///
666///
667/// This macro is defined if the compiler supports `[[maybe_unused]]` C++17
668/// attribute syntax.
669///
670/// * Compiler support:
671/// - GCC 4.8
672/// - Clang 3.3
673/// - Visual Studio 2017 version 15.3 (<u>MSC</u>VER 1911)
674///
675/// ### BSLS_COMPILERFEATURES_SUPPORT_CONCEPTS {#bsls_compilerfeatures-bsls_compilerfeatures_support_concepts}
676///
677///
678/// This macro is defined if the concepts core language feature is fully
679/// supported, as defined by ISO C++20.
680///
681/// This macro is defined if the standard `__cpp_concepts` feature-test macro
682/// has at least `202002L` value.
683///
684/// * Compiler support:
685/// - GCC 12.1
686/// - Visual Studio 2022 version 17.2.2 (<u>MSC</u>VER 1932)
687///
688/// Note that clang 16.0 still has a bug that prevents it declaring C++20
689/// concepts support. (At the time of writing (2023.Jun.01) clang `trunk` does
690/// not yet declare C++20 concepts to be available, `_cpp_concepts` is
691/// 201907LL).
692///
693/// ### BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR {#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr}
694///
695///
696/// This macro is defined in the compiler supports the `constexpr` reserved
697/// keyword.
698///
699/// * Compiler support:
700/// - GCC 4.7
701/// - Clang 3.1
702/// - IBM xlC 13
703/// - Oracle CC 12.4
704///
705/// ### BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14 {#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr_cpp14}
706///
707///
708/// This macro is defined in the compiler supports the `constexpr` reserved
709/// keyword with C++14 semantics.
710///
711/// * Compiler support:
712/// - gcc 6
713/// - clang 3.4
714/// - Visual Studio 2017 version 15.0 (<u>MSC</u>VER 1910)
715///
716/// ### BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17 {#bsls_compilerfeatures-bsls_compilerfeatures_support_constexpr_cpp17}
717///
718///
719/// This macro is defined if the compiler supports the `constexpr` reserved
720/// keyword with C++17 semantics.
721///
722/// * Compiler support:
723/// - gcc 7.3
724/// - clang 5
725/// - Visual Studio 2017 version 15.0 (<u>MSC</u>VER 1910)
726///
727/// ### BSLS_COMPILERFEATURES_SUPPORT_COROUTINE {#bsls_compilerfeatures-bsls_compilerfeatures_support_coroutine}
728///
729///
730/// This macro is defined if the compiler supports at least the C++20 coroutine
731/// core language features and also provides the `<coroutine>` standard header
732/// providing the basic library facilities necessary to make use of coroutines.
733///
734/// * Compiler support (in C++20 mode):
735/// - gcc 11.1
736/// - clang 14
737/// - Visual Studio 2019 version 16.11 (<u>MSC</u>VER 1929)
738///
739/// ### BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE {#bsls_compilerfeatures-bsls_compilerfeatures_support_decltype}
740///
741///
742/// This macro is defined if the compiler supports the `decltype` reserved word.
743///
744/// * Compiler support:
745/// - GCC 4.3
746/// - Clang 3.3
747/// - Visual Studio 2010 version 10.0 (<u>MSC</u>VER 1600)
748/// - IBM xlC 11.1
749/// - Oracle CC 12.4
750///
751/// ### BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS {#bsls_compilerfeatures-bsls_compilerfeatures_support_default_template_args}
752///
753///
754/// This macro is defined if the compiler supports syntax to introduce defaulted
755/// functions.
756///
757/// * Compiler support:
758/// - GCC 4.3
759/// - Clang 2.9
760/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
761/// - IBM xlC not supported?
762/// - Oracle CC 12.4
763///
764/// ### BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS {#bsls_compilerfeatures-bsls_compilerfeatures_support_defaulted_functions}
765///
766///
767/// This macro is defined if the compiler supports syntax to introduce defaulted
768/// functions.
769///
770/// * Compiler support:
771/// - GCC 4.4
772/// - Clang 2.9
773/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
774/// - IBM xlC 13.1
775/// - Oracle CC 12.4
776///
777/// ### BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS {#bsls_compilerfeatures-bsls_compilerfeatures_support_deleted_functions}
778///
779///
780/// This macro is defined if the compiler supports syntax to introduce deleted
781/// functions.
782///
783/// * Compiler support:
784/// - GCC 4.4
785/// - Clang 2.9
786/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
787/// - IBM xlC 13.1
788/// - Oracle CC 12.4
789///
790/// ### BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE {#bsls_compilerfeatures-bsls_compilerfeatures_support_extern_template}
791///
792///
793/// This macro is defined if the compiler supports allowing suppression of
794/// implicit instantiation of templates by prefixing an explicit instantiation
795/// directive with the `extern` keyword.
796///
797/// * Compiler support:
798/// - GCC 3.3
799/// - Clang (any)
800/// - Visual Studio 2010 version 10.0 (<u>MSC</u>VER 1600)
801/// - IBM xlC 11.1
802/// - Oracle CC 12.4
803///
804/// ### BSLS_COMPILERFEATURES_SUPPORT_FINAL {#bsls_compilerfeatures-bsls_compilerfeatures_support_final}
805///
806///
807/// This macro is defined if the compiler supports both finalizing a class using
808/// the `final` keyword after the class name as well as preventing further
809/// derived classes from overriding a `virtual` function by using `final` after
810/// its signature.
811///
812/// * Compiler support:
813/// - GCC 4.7
814/// - Clang 3.0
815/// - Visual Studio 2012 version 11.0 (<u>MSC</u>VER 1700)
816/// - IBM xlC 11.1
817/// - Oracle CC 12.4
818///
819/// ### BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS {#bsls_compilerfeatures-bsls_compilerfeatures_support_generalized_initializers}
820///
821///
822/// This macro is defined if the compiler supports generalized initializers.
823///
824/// * Compiler support:
825/// - GCC 4.4
826/// - Clang 3.1
827/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
828/// - IBM xlC not supported
829/// - Oracle CC 13
830///
831/// ### BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE {#bsls_compilerfeatures-bsls_compilerfeatures_support_has_include}
832///
833///
834/// This macro is defined if the compiler supports `__has_include` semantics as
835/// defined in the C++17 Standard (see also P006R1). Note that this
836/// preprocessor feature is often available in earlier language dialects.
837///
838/// * Compiler support:
839/// - GCC 5.0
840/// - clang (any)
841/// - Visual Studio 2017 version 15.3 (<u>MSC</u>VER 1911)
842///
843/// ### BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT {#bsls_compilerfeatures-bsls_compilerfeatures_support_include_next}
844///
845///
846/// This macro is defined if the compiler supports #include_next.
847///
848/// * Compiler support:
849/// - GCC (any)
850/// - Clang (any)
851/// - IBM xlC 8
852/// - Oracle CC 12.4
853///
854/// ### BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE {#bsls_compilerfeatures-bsls_compilerfeatures_support_inline_namespace}
855///
856///
857/// This macro is defined if the compiler supports `inline` namespaces
858/// introduced in the C++11 Standard.
859///
860/// * Compiler support:
861/// - GCC 4.4
862/// - Clang 2.9
863/// - Visual Studio 2015 version 14.0 (<u>MSC</u>VER 1900)
864/// - IBM xlC 11.1
865/// - Oracle CC 12.4
866///
867/// ### BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES {#bsls_compilerfeatures-bsls_compilerfeatures_support_inline_variables}
868///
869///
870/// This macro is defined if the compiler supports `inline` variables introduced
871/// in the C++17 Standard.
872///
873/// * Compiler support:
874/// - GCC 7.0
875/// - Clang 3.9
876/// - Visual Studio 2017 version 15.5 (<u>MSC</u>VER 1912)
877///
878/// ### BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT {#bsls_compilerfeatures-bsls_compilerfeatures_support_noexcept}
879///
880///
881/// This macro is defined if the compiler supports the `noexcept` reserved
882/// keyword.
883///
884/// * Compiler support:
885/// - GCC 4.6
886/// - Clang 3.0
887///
888/// ### BSLS_COMPILERFEATURES_SUPPORT_NULLPTR {#bsls_compilerfeatures-bsls_compilerfeatures_support_nullptr}
889///
890///
891/// This macro is defined if the compiler supports the `nullptr` reserved word.
892///
893/// * Compiler support:
894/// - GCC 4.6
895/// - Clang 3.0
896/// - Visual Studio 2010 version 10.0 (<u>MSC</u>VER 1600)
897/// - IBM xlC 13.1
898/// - Oracle CC 12.4
899///
900/// ### BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT {#bsls_compilerfeatures-bsls_compilerfeatures_support_operator_explicit}
901///
902///
903/// This macro is defined if the compiler supports use of the `explicit` keyword
904/// to indicate that a conversion operator only available for explicit
905/// conversions.
906///
907/// * Compiler support:
908/// - GCC 4.5
909/// - Clang 3.0
910/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
911/// - IBM xlC 11.1
912/// - Oracle CC 12.4
913///
914/// ### BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE {#bsls_compilerfeatures-bsls_compilerfeatures_support_override}
915///
916///
917/// This macro is defined if the compiler supports use of the `override` keyword
918/// to indicate that a member function is meant to override a `virtual` function
919/// (and cause a failure if that is not the case).
920///
921/// * Compiler support:
922/// - GCC 4.7
923/// - Clang 3.0
924/// - Visual Studio 2012 version 11.0 (<u>MSC</u>VER 1700)
925/// - IBM xlC 11.1
926/// - Oracle CC 12.4
927///
928/// ### BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS {#bsls_compilerfeatures-bsls_compilerfeatures_support_raw_strings}
929///
930///
931/// This macro is defined if the compiler supports the use of C++11-style
932/// R"tag(string)tag" strings.
933///
934/// * Compiler support:
935/// - GCC 4.5
936/// - Clang 3.3
937/// - Visual Studio 2013 version 12.0 (<u>MSC</u>VER 1800)
938/// - xlC 13.1.3 (Not yet supported by this component)
939/// - Oracle CC 12.4
940///
941/// ### BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS {#bsls_compilerfeatures-bsls_compilerfeatures_support_ref_qualifiers}
942///
943///
944/// This macro is defined if member functions with trailing reference qualifiers
945/// (e.g., `void myfunc(int) &`) and rvalue reference qualifiers (e.g.,
946/// `void myFunc(int) &&`) are supported. Note that this macro implies that
947/// `BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES` is also defined.
948///
949/// * Compiler support:
950/// - gcc 4.5 (rvalue references v2.1; original draft support in gcc 4.3 is
951/// not correct with respect to final spec (v3.0))
952/// - clang 2.9
953/// - Visual Studio 2015 version 14.0 (<u>MSC</u>VER 1900)
954/// - xlC 12.1
955/// - Oracle CC 12.4
956///
957/// ### BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES {#bsls_compilerfeatures-bsls_compilerfeatures_support_rvalue_references}
958///
959///
960/// This macro is defined if the compiler supports rvalue references and move
961/// semantics compatible with the final C++11 specification. (Semantics have
962/// changed since early draft proposals.)
963///
964/// * Compiler support:
965/// - GCC 4.5 (rvalue references v2.1; original draft support in GCC 4.3 is
966/// not correct with respect to final spec (v3.0))
967/// - Clang 2.9
968/// - Visual Studio 2010 version 10.0 (<u>MSC</u>VER 1600)
969/// - IBM xlC 12.1
970/// - Oracle CC 12.4
971///
972/// ### BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT {#bsls_compilerfeatures-bsls_compilerfeatures_support_static_assert}
973///
974///
975/// This macro is defined if the compiler supports the @ref static_assert reserved
976/// word.
977///
978/// * Compiler support:
979/// - GCC 4.3
980/// - Clang 2.9
981/// - Visual Studio 2010 version 10.0 (<u>MSC</u>VER 1600)
982/// - IBM xlC 11.1
983/// - Oracle CC 12.4
984///
985/// ### BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON {#bsls_compilerfeatures-bsls_compilerfeatures_support_three_way_comparison}
986///
987///
988/// This macro is defined if the compiler supports `<=>` operator.
989///
990/// * Compiler support:
991/// - GCC 10.1
992/// - Clang 11.0
993/// - Visual Studio 2019 version 16.11 (<u>MSC</u>VER 1929)
994///
995/// ### BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES {#bsls_compilerfeatures-bsls_compilerfeatures_support_variadic_templates}
996///
997///
998/// This macro is defined if the compiler supports the ability to express a
999/// template that accepts an arbitrary number of parameters in a type-safe
1000/// manner.
1001///
1002/// * Compiler support:
1003/// - GCC 4.3
1004/// - Clang 2.9
1005/// - Visual Studio 2015 version 14.0 (<u>MSC</u>VER 1900)
1006/// - IBM xlC 11.1
1007/// - Oracle CC 12.4
1008///
1009/// ### BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES {#bsls_compilerfeatures-bsls_compilerfeatures_support_variable_templates}
1010///
1011///
1012/// This macro is defined if the compiler supports variable templates introduced
1013/// in the C++14 Standard.
1014///
1015/// * Compiler support:
1016/// - gcc 5.0
1017/// - clang 3.4
1018/// - Visual Studio 2015 version 14.0 (<u>MSC</u>VER 1900)
1019/// - Oracle CC 12.4
1020///
1021/// ## Microsoft Visual Studio versions mapping {#bsls_compilerfeatures-microsoft-visual-studio-versions-mapping}
1022///
1023///
1024/// Microsoft Visual C++ in Microsoft Visual Studio has *many* different
1025/// associated versions:
1026///
1027/// * Microsoft Visual Studio release name (such as 2015, 2019, 2022 etc.)
1028/// * Microsoft Visual Studio update number (such as Update 6)
1029/// * Microsoft Visual Studio version number (such as 15.6.1)
1030/// * Microsoft Visual C++ Toolset version number (such as 14.30)
1031/// * C++ compiler version number and `_MSVC_VER` (such as 19.32 and 1932)
1032/// * C++ compiler `_MSVC_FULL_VER` (such as 193231329)
1033///
1034/// The following table shows the mapping between the different version numbers.
1035/// The source for the table was
1036/// https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd
1037/// and the `_MSC_VER` entry on
1038/// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
1039/// at 2020-12-13 20:00-05:00 (EST/New York).
1040///
1041/// @code
1042/// +-------------------+----------+---------+----------+---------------+
1043/// | Visual Studio name & version | Toolset | _MSC_VER | _MSC_FULL_VER |
1044/// +===================+==========+=========+==========+===============+
1045/// | 2015 | 14.0 | 14.0 | 1900 | 190023026 |
1046/// | 2015 Update 1 | 14.0 | 14.0 | 1900 | 190023506 |
1047/// | 2015 Update 2 | 14.0 | 14.0 | 1900 | 190023918 |
1048/// | 2015 Update 3 | 14.0 | 14.0 | 1900 | 190024210 |
1049/// +-------------------+----------+---------+----------+---------------+
1050/// | 2017 | 15.0 | 14.10 | 1910 | 191025017 |
1051/// | 2017 Update 1 | 15.1 | 14.10 | 1910 | 191025017 |
1052/// | 2017 Update 2 | 15.2 | 14.10 | 1910 | 191025017 |
1053/// | 2017 Update 3 | 15.3.3 | 14.11 | 1911 | 191125507 |
1054/// | 2017 Update 4 | 15.4.4 | 14.11 | 1911 | 191125542 |
1055/// | Update 4(*) | 15.4.5 | 14.11 | 1911 | 191125547 |
1056/// | 2017 Update 5 | 15.5.2 | 14.12 | 1912 | 191225831 |
1057/// | Update 5(*) | 15.5.3 | 14.12 | 1912 | 191225834 |
1058/// | Update 5(*) | 15.5.4 | 14.12 | 1912 | 191225834 |
1059/// | Update 5(*) | 15.5.6 | 14.12 | 1912 | 191225835 |
1060/// | Update 5(*) | 15.5.7 | 14.12 | 1912 | 191225835 |
1061/// | 2017 Update 6 | 15.6.0 | 14.13 | 1913 | 191326128 |
1062/// | Update 6(*) | 15.6.1 | 14.13 | 1913 | 191326128 |
1063/// | Update 6(*) | 15.6.2 | 14.13 | 1913 | 191326128 |
1064/// | Update 6(*) | 15.6.3 | 14.13 | 1913 | 191326129 |
1065/// | Update 6(*) | 15.6.4 | 14.13 | 1913 | 191326129 |
1066/// | Update 6(*) | 15.6.6 | 14.13 | 1913 | 191326131 |
1067/// | Update 6(*) | 15.6.7 | 14.13 | 1913 | 191326132 |
1068/// | 2017 Update 7 | 15.7.1 | 14.14 | 1914 | 191426428 |
1069/// | Update 7(*) | 15.7.2 | 14.14 | 1914 | 191426429 |
1070/// | Update 7(*) | 15.7.3 | 14.14 | 1914 | 191426430 |
1071/// | Update 7(*) | 15.7.5 | 14.14 | 1914 | 191426433 |
1072/// | 2017 Update 8 | 15.8.0 | 14.15 | 1915 | ? |
1073/// | 2017 Update 9 | 15.9.0 | 14.16 | 1916 | ? |
1074/// | Update 9(*) | 15.9.1 | 14.16 | 1916 | 191627023 |
1075/// | Update 9(*) | 15.9.4 | 14.16 | 1916 | 191627025 |
1076/// | Update 9(*) | 15.9.5 | 14.16 | 1916 | 191627026 |
1077/// | Update 9(*) | 15.9.7 | 14.16 | 1916 | 191627027 |
1078/// | Update 9(*) | 15.9.11 | 14.16 | 1916 | 191627030 |
1079/// +-------------------+----------+---------+----------+---------------+
1080/// | 2019 | 16.0 | 14.20 | 1920 | 192027508 |
1081/// | 2019 Update 1 | 16.1.2 | 14.21 | 1921 | 192127702 |
1082/// | 2019 Update 2 | 16.2.3 | 14.21 | 1922 | 192227905 |
1083/// | 2019 Update 3 | 16.3.2 | 14.21 | 1923 | 192328105 |
1084/// | 2019 Update 4 | 16.4.0 | 14.24 | 1924 | 192428314 |
1085/// | 2019 Update 5 | 16.5.1 | 14.25 | 1925 | 192528611 |
1086/// | 2019 Update 6 | 16.6.2 | 14.26 | 1926 | 192628806 |
1087/// | 2019 Update 7 | 16.7 | 14.27 | 1927 | 192729112 |
1088/// | 2019 Update 8 | 16.8.1 | 14.28 | 1928 | 192829333 |
1089/// | Update 8(*) | 16.8.2 | 14.28 | 1928 | 192829334 |
1090/// | 2019 Update 9 | 16.9.2 | 14.28 | 1928 | 192829913 |
1091/// | 2019 Update 11 | 16.11.2 | 14.28 | 1929 | 192930133 |
1092/// +-------------------+----------+---------+----------+---------------+
1093/// | 2022 | 17.0.1 | 14.30 | 1930 | 193030705 |
1094/// | 2022(*) | 17.0.2 | 14.30 | 1930 | 193030706 |
1095/// | 2022(*) | 17.2.2 | 14.30 | 1932 | 193231329 |
1096/// | 2022(*) | 17.3.4 | 14.30 | 1933 | 193331630 |
1097/// +-------------------+----------+---------+----------+---------------+
1098/// @endcode
1099/// (*) Visual Studio may receive interim updates that do not contribute into
1100/// the Visual Studio "human friendly" version, but are visible in other
1101/// version numbers.
1102///
1103/// @code
1104/// ####################################################################
1105/// ########################################################################
1106/// ## ##
1107/// ## THIS HEADER FILE HAS SPECIAL FORMATTING RULES! ##
1108/// ## ************************************************ ##
1109/// ## ##
1110/// ## Please follow the rules when updating it. For specific reasons and ##
1111/// ## details please see {Special Formatting Rules and Allowances} above. ##
1112/// ## ##
1113/// ########################################################################
1114/// ####################################################################
1115/// @endcode
1116/// @}
1117/** @} */
1118/** @} */
1119
1120/** @addtogroup bsl
1121 * @{
1122 */
1123/** @addtogroup bsls
1124 * @{
1125 */
1126/** @addtogroup bsls_compilerfeatures
1127 * @{
1128 */
1129
1130#include <bsls_platform.h>
1131#include <bsls_macrorepeat.h>
1132
1133#ifdef __has_include
1134 #if __has_include(<version>)
1135 #include <version>
1136 #endif
1137#endif
1138
1139// ============================================================================
1140// VERIFY COMPILER VERSION SUPPORT FOR REQUESTED ISO LANGUAGE
1141// ============================================================================
1142
1143#ifndef BDE_BUILD_SKIP_VERSION_CHECKS
1144
1145 // Some level of C++20 is enabled, let's verify the compiler is supported
1146 #if __cplusplus > 201703L || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
1147 #if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION < 110100
1148 static_assert(0, "At least version 11.1 is required for C++20 support "
1149 "in GNU CC g++. This check can be disabled by defining the "
1150 "'BDE_BUILD_SKIP_VERSION_CHECKS' build flag.");
1151 #endif // Too old gcc for C++20
1152
1153 #if defined(BSLS_PLATFORM_CMP_CLANG) && BSLS_PLATFORM_CMP_VERSION < 150000
1154 static_assert(0, "At least version 15.0 is required for C++20 support "
1155 "in LLVM clang. This check can be disabled by defining the "
1156 "'BDE_BUILD_SKIP_VERSION_CHECKS' build flag.");
1157 #endif // Too old clang for C++20
1158
1159 #if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1930
1160 static_assert(0, "At least version 19.30 is required for C++20 support "
1161 "in MS Visual C++ (MS Visual Studio 2022). This check can be "
1162 "disabled by defining build flag 'BDE_BUILD_SKIP_VERSION_CHECKS'.");
1163 #endif // Too old MSVC for C++20
1164
1165 #if defined(BSLS_PLATFORM_CMP_IBM) || defined(BSLS_PLATFORM_CMP_SUN)
1166 #error "This compiler does not support C++20. This check can be " \
1167 "disabled by defining the 'BDE_BUILD_SKIP_VERSION_CHECKS' build "\
1168 "flag. See also " \
1169"http://bloomberg.github.io/bde/library_information/supported_platforms.html "\
1170 "for all compiler and other platform requirements."
1172 #endif // No C++20 on big iron
1173 #endif // C++20 features requested
1174#endif // ifndef BDE_BUILD_SKIP_VERSION_CHECKS
1175
1176// ============================================================================
1177// UNIVERSAL MACRO DEFINITIONS
1178// ============================================================================
1179
1180#if defined(__cplusplus)
1181 #define BSLS_COMPILERFEATURES_CPLUSPLUS __cplusplus
1182#else
1183 #define BSLS_COMPILERFEATURES_CPLUSPLUS 199711L
1184#endif
1185
1186// First, define feature macros for any C++98 features that should be available
1187// on all compilers, until removed by a later standard. These macros will be
1188// specifically undefined when compilers stop supporting that feature in a
1189// modern build mode.
1190#define BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS 1
1191
1192// Use the standard compiler-independent feature-test macros (SD-6) for
1193// compilers that support them. This support will be mandated by C++20, and it
1194// is expected that, at some point, future compilers will need only these
1195// universal definitions, and the platform-specific detection below will need
1196// no further maintenance.
1197#if defined(__cpp_guaranteed_copy_elision)
1198 #define BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION 1
1199#endif
1200
1201#if defined(__cpp_unicode_characters) && defined(__cpp_unicode_literals)
1202 #define BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES 1
1203#endif
1204
1205#if defined(__cpp_char8_t)
1206 #define BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE 1
1207#endif
1208
1209#if defined(__cpp_hex_float)
1210 #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS 1
1211#endif
1212
1213#if defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L
1214 // && defined(__cpp_lib_coroutine) && __cpp_lib_coroutine >= 201902L
1215 //
1216 // There are no known compilers that define the core language feature macro
1217 // but do not provide the corresponding library header. As *this* header
1218 // is included into almost every translation unit we won't
1219 // '#include <coroutine>' or the '<version>' standard headers (that would
1220 // '#define __cpp_lib_coroutine'), but we verify the presence and value of
1221 // '__cpp_lib_coroutine' both in the implementation file and the test
1222 // driver.
1223 #define BSLS_COMPILERFEATURES_SUPPORT_COROUTINE 1
1224#endif
1225
1226#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201611
1227 #define BSLS_COMPILERFEATURES_SUPPORT_CTAD 1
1228#endif
1229
1230#if defined(__cpp_concepts) && __cpp_concepts >= 202002L
1231 #define BSLS_COMPILERFEATURES_SUPPORT_CONCEPTS 1
1232#endif
1233
1234#if defined(__cpp_impl_three_way_comparison) && \
1235 __cpp_impl_three_way_comparison >= 201907L
1236 #if defined(__cpp_lib_three_way_comparison) && \
1237 __cpp_lib_three_way_comparison >= 201907L
1238 #define BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON 1
1239 #endif
1240#endif
1241
1242// ============================================================================
1243// ATTRIBUTE DETECTION
1244// ============================================================================
1245
1246#if (__cplusplus >= 201103L) && defined(__has_cpp_attribute)
1247
1248 #if __has_cpp_attribute(fallthrough)
1249 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH 1
1250 #endif
1251
1252 #if __has_cpp_attribute(noreturn)
1253 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN 1
1254 #endif
1255
1256 #if __has_cpp_attribute(nodiscard)
1257 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD 1
1258 #endif
1259
1260 #if __has_cpp_attribute(maybe_unused)
1261 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED 1
1262 #endif
1263
1264#endif
1265
1266// ============================================================================
1267// PLATFORM SPECIFIC FEATURE DETECTION AND MACRO DEFINITIONS
1268// ============================================================================
1269
1270// ============================================================================
1271// GNU Compiler Collection / gcc and g++
1272// ============================================================================
1273
1274//GCC
1275// https://wiki.apache.org/stdcxx/C%2B%2B0xCompilerSupport
1276// As GCC tracked the evolving C++11 standard, earlier versions of the compiler
1277// have implementations of earlier specifications of features that can show up
1278// as bugs compared to the final standard. Therefore, BDE does not attempt to
1279// support C++11 in GCC compilers prior to the 4.8 release.
1280#if defined(BSLS_PLATFORM_CMP_GNU)
1281
1282 #define BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT 1
1283
1284 #if BSLS_PLATFORM_CMP_VERSION >= 30300
1285 #define BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE 1
1286 #endif // version >= 3.3
1287
1288 // GCC provides support to the following features, prior to C++17,
1289 // independent of language dialect.
1290 #if BSLS_PLATFORM_CMP_VERSION >= 50000
1291
1292 #ifndef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1293 #define BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION 1
1294 #endif // feature test macro may have already defined this
1295
1296 #define BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE 1
1297 #endif // at least gcc 5.0
1298
1299 #if BSLS_PLATFORM_CMP_VERSION < 120000
1300 #define BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS 1
1301 #endif // before gcc 12.0
1302
1303 #if !defined(__GXX_EXPERIMENTAL_CXX0X__) || \
1304 (__cplusplus < 201500 && defined(__STRICT_ANSI__))
1305 // Supported gcc compilers *always* define '__cpp_hex_float', even if the
1306 // core language feature is not supported in the current configuration of
1307 // a build, and they define it to the exact same value ('201603LL')
1308 // regardless of actual support for literals. We remedy this by
1309 // undefining the hexfloat-literal-support macro in those cases when it
1310 // is not really supported, but gcc said so. There are 2 such cases:
1311 //: 1 Language mode is below C++11
1312 //: 2 Language mode is below C++17 experimental core language support and
1313 //: GNU extensions are not enabled.
1314 //
1315 // '__GXX_EXPERIMENTAL_CXX0X__' is defined when at least basic C++11
1316 // features are present (should be used instead of '__cplusplus').
1317 // g++ defines the '__cplusplus' macro to the non-standard value of
1318 // 201500 to indicate experimental C++17 support.
1319 #if defined(BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS)
1320 #undef BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1321 #endif // '__cpp_hex_float' was defined, but is not supported.
1322 #endif // No C++11 or GNU extensions not enabled, C++17 not enabled
1323
1324 // GCC -std=c++11 or -std=c++0x or -std=gnu++11 or -std=gnu++0x
1325 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
1326
1327 #if BSLS_COMPILERFEATURES_CPLUSPLUS < 201103L
1328 #undef BSLS_COMPILERFEATURES_CPLUSPLUS
1329 #define BSLS_COMPILERFEATURES_CPLUSPLUS 201103L
1330 #endif // C++ standard date was set to older standard than C++11
1331
1332 #if BSLS_PLATFORM_CMP_VERSION >= 40800
1333 #define BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES 1
1334 #define BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS 1
1335
1336 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN 1
1337 // GCC supports '__attribute__((noreturn))' in earlier versions
1338
1339 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR 1
1340 #define BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE 1
1341 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS 1
1342 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS 1
1343 #define BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS 1
1344 #define BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS 1
1345 #define BSLS_COMPILERFEATURES_SUPPORT_FINAL 1
1346 #define BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS 1
1347 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE 1
1348 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT 1
1349 #define BSLS_COMPILERFEATURES_SUPPORT_NULLPTR 1
1350 #define BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT 1
1351 #define BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE 1
1352 #define BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS 1
1353 #define BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS 1
1354 #define BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES 1
1355 #define BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT 1
1356 #define BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES 1
1357 #define BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS 1
1358 #endif // at least gcc 4.8
1359
1360 #if BSLS_PLATFORM_CMP_VERSION >= 50000
1361 #define BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER 1
1362 // Note that while basic support is available in earlier versions
1363 // of the library, the full header is not implemented until gcc 5.0.
1364 #endif // at least gcc 5.0
1365 #endif // at least C++11
1366
1367 #if BSLS_PLATFORM_CMP_VERSION >= 90000
1368 #define BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST 1
1369 #endif // at least gcc 9.0
1370
1371 #if __cplusplus >= 201402L
1372 // Don't enable (not fully supported) extended constexpr rules for gcc 5.x.
1373 // See {DRQS 164511755} for details.
1374 #if BSLS_PLATFORM_CMP_VERSION >= 60000
1375 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14 1
1376 #endif // at least gcc 6.0
1377
1378 #define BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES 1
1379 #endif // at least C++14
1380
1381 // GCC defines the '__cplusplus' macro to the non-standard value of 201500 to
1382 // indicate experimental C++17 support.
1383 #if __cplusplus >= 201500
1384
1385 #if BSLS_PLATFORM_CMP_VERSION >= 70000
1386 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH 1
1387 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED 1
1388 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17 1
1389 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES 1
1390
1391 #ifndef BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1392 #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS 1
1393 #endif // feature test macro may have already defined this
1394
1395 // C++98 throw specifications are removed in C++17 mode
1396 #undef BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS
1397 #endif // at least gcc 7.0
1398
1399 #if BSLS_PLATFORM_CMP_VERSION >= 70200
1400 // Early release of gcc 7.0 have a name-mangling bug with 'noexcept' on
1401 // "abominable" function types.
1402 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE 1
1403 #endif // at least gcc 7.2
1404 #endif // at least experimental C++17 support
1405#endif // GNU Compiler Collection C++
1406
1407// ============================================================================
1408// LLVM Clang and Apple Clang / clang and clang++
1409// ============================================================================
1410
1411//Clang
1412// http://clang.llvm.org/cxx_status.html
1413// http://clang.llvm.org/docs/LanguageExtensions.html
1414#if defined(BSLS_PLATFORM_CMP_CLANG)
1415
1416 #ifndef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1417 #define BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION 1
1418 #endif // feature test macro may have already defined this
1419
1420 #define BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE 1
1421
1422 #ifndef BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1423 #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS 1
1424 #endif // feature test macro may have already defined this
1425
1426 #define BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT 1
1427 #define BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE 1
1428
1429 // clang -std=c++11 or -std=c++0x or -std=gnu++11 or -std=gnu++0x Clang 2.9
1430 #if __has_feature(cxx_rvalue_references)
1431 #define BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES 1
1432 #endif
1433
1434 #if __has_feature(cxx_reference_qualified_functions) && \
1435 __has_feature(cxx_rvalue_references)
1436 #define BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS 1
1437 #endif
1438
1439 #if __has_feature(cxx_default_function_template_args)
1440 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS 1
1441 #endif
1442
1443 #if __has_feature(cxx_defaulted_functions)
1444 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS 1
1445 #endif
1446
1447 #if __has_feature(cxx_deleted_functions)
1448 #define BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS 1
1449 #endif
1450
1451 #if __has_feature(cxx_static_assert)
1452 #define BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT 1
1453 #endif
1454
1455 #if __has_feature(cxx_inline_namespaces) || \
1456 __has_extension(cxx_inline_namespaces)
1457 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE 1
1458 #endif
1459
1460 #if __has_feature(cxx_variadic_templates)
1461 #define BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES 1
1462 #endif
1463
1464 // Clang 3.0
1465 #if __has_feature(cxx_alias_templates)
1466 #define BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES 1
1467 #endif
1468
1469 #if __has_feature(cxx_noexcept)
1470 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT 1
1471 #endif
1472
1473 #if __has_feature(cxx_raw_string_literals)
1474 #define BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS 1
1475 #endif
1476
1477 // Clang 3.1
1478 #if __has_feature(cxx_constexpr)
1479 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR 1
1480 #endif
1481
1482 #if __has_feature(cxx_user_literals)
1483 #define BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS 1
1484 #endif
1485
1486 // Clang 3.4
1487 #if __has_feature(cxx_relaxed_constexpr)
1488 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14 1
1489 #endif
1490
1491 #if __has_feature(cxx_explicit_conversions)
1492 #define BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT 1
1493 #endif
1494
1495 #if __has_feature(cxx_override_control)
1496 #define BSLS_COMPILERFEATURES_SUPPORT_FINAL 1
1497 #define BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE 1
1498 #endif
1499
1500 #if __has_feature(cxx_nullptr)
1501 #define BSLS_COMPILERFEATURES_SUPPORT_NULLPTR 1
1502 #endif
1503
1504 // Clang 3.1
1505 #if __has_feature(cxx_generalized_initializers)
1506 #define BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS 1
1507 #endif
1508
1509 #if __has_feature(cxx_alignas)
1510 #define BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS 1
1511 #endif
1512
1513 // Clang 3.3
1514 #if __has_feature(cxx_decltype)
1515 #define BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE 1
1516 #endif
1517
1518 // Clang 3.4
1519 #if __has_feature(cxx_variable_templates)
1520 #define BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES 1
1521 #endif
1522
1523 #if __has_feature(cxx_attributes)
1524 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN 1
1525 // Note that Clang supports __attribute__((noreturn)) in earlier versions
1526 #endif
1527
1528 #if BSLS_COMPILERFEATURES_CPLUSPLUS < 201103L && \
1529 defined(__GXX_EXPERIMENTAL_CXX0X__)
1530 #undef BSLS_COMPILERFEATURES_CPLUSPLUS
1531 #define BSLS_COMPILERFEATURES_CPLUSPLUS 201103L
1532 #endif // too old standard date fixed up
1533
1534 #if (__cplusplus >= 201103L || \
1535 (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(__APPLE_CC__))) \
1536 && __has_include(<type_traits>)
1537 #define BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER 1
1538 #endif // at least C++11 support and has the header
1539
1540 // works only with --std=c++1z or --std=c++17
1541 #if __cplusplus >= 201703L // at least C++17
1542 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17 1
1543 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES 1
1544 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE 1
1545 #endif // at least C++17
1546
1547 // When compiling in >= C++11 mode on a non-Darwin platform, assume that the
1548 // Clang version is at least 3.0 and accompanied by a GCC toolchain that is
1549 // at least version 4.8 and which supports clang.
1550 #if defined(__GXX_EXPERIMENTAL_CXX0X__) && \
1551 (!defined(__APPLE_CC__) || __APPLE_CC__ >= 6000)
1552 #define BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER 1
1553 #endif
1554
1555 // clang does not yet follow WG14 N2322 Recommended practice
1556 // #define BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST
1557#endif // Clang
1558
1559// ============================================================================
1560// Microsoft Visual Studio / MSVC / cl.exe
1561// ============================================================================
1562
1563//MSVC (Minimum supported version is MSVC 2015)
1564// http://msdn.microsoft.com/en-us/library/hh567368.aspx
1565// http://blogs.msdn.com/b/vcblog/archive/2014/06/11/c-11-14-feature-tables-for-visual-studio-14-ctp1.aspx
1566#if defined(BSLS_PLATFORM_CMP_MSVC)
1567
1568// MSVC enables C++11 features automatically in versions that provide the
1569// feature. Features can not be disabled.
1570//
1571//: * extern template is not supported. It is documented as being "supported"
1572//: but behaves in a non-conforming manner.
1573
1574 #if BSLS_PLATFORM_CMP_VERSION < 1900
1575 #error Earliest supported toolset version is 19.0, Visual Studio 2015
1577 // Too old compiler, not supported.
1578 #endif // Earlier than Visual Studio 2015
1579
1580 // Not only does Microsoft not always report the language dialect properly in
1581 // '__cplusplus', many users depends upon it not reflecting the right
1582 // version, therefore we need to use the Microsoft specific predefined macro
1583 // '_MSVC_LANG'. See https://goo.gl/ikfyDw and
1584 // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
1585 // Note that '_MSVC_LANG' is only useful for distinguishing MSVC 2017 from
1586 // MSVC 2014.
1587 #undef BSLS_COMPILERFEATURES_CPLUSPLUS
1588 #if defined(_MSVC_LANG)
1589 #define BSLS_COMPILERFEATURES_CPLUSPLUS _MSVC_LANG
1590 #else
1591 #define BSLS_COMPILERFEATURES_CPLUSPLUS 201103L
1592 #endif // _MSVC_LANG
1593
1594 #undef BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS
1595 // MSVC has never properly implemented this feature, even before it was
1596 // removed by C++17. It would parse the syntax, but the runtime behavior
1597 // simply would simply ignore the exception specification.
1598
1599 // These features are supported in the lowest version of MSVC we support
1600 #define BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES 1
1601 #define BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE 1
1602 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS 1
1603 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS 1
1604 #define BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS 1
1605 #define BSLS_COMPILERFEATURES_SUPPORT_FINAL 1
1606 #define BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS 1
1607 #define BSLS_COMPILERFEATURES_SUPPORT_NULLPTR 1
1608 #define BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE 1
1609 #define BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS 1
1610 #define BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES 1
1611 #define BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT 1
1612 #define BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER 1
1613
1614 #ifndef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1615 #define BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION 1
1616 #endif // feature test macro may have already defined this
1617
1618 #define BSLS_COMPILERFEATURES_SUPPORT_ALIGNAS 1
1619 #define BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS 1
1620 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT 1
1621 #define BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT 1
1622 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE 1
1623 #define BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS 1
1624
1625 #ifndef BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES
1626 #define BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES 1
1627 #endif // feature test macro may have already defined this
1628
1629 // The variable template C++14 compiler feature is supported since Microsoft
1630 // Visual Studio 2015 update 2 toolset '_MSC_FULL_VER' 190023918.
1631 #if _MSC_FULL_VER >= 190023918
1632 #define BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES 1
1633 #endif // at least Microsoft Visual Studio 2015 Update 2
1634
1635 #define BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES 1
1636 #define BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS 1
1637
1638 #if BSLS_PLATFORM_CMP_VERSION >= 1910 // Microsoft Visual Studio 2017
1639 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR 1
1640 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14 1
1641
1642 #if BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
1643 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_FALLTHROUGH 1
1644 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17 1
1645 #endif // at least C++17
1646 #endif // at least Microsoft Visual Studio 2017
1647
1648 // MSVC does not support the non-standard '#include_next' directive
1649 //#define BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT
1650
1651 // Not yet enabling 'noexcept' function types, but pro-active test drivers
1652 // may want to add coverage.
1653 // #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE
1654
1655 // MS Visual Studio 2017 Update 4, toolset version 14.11
1656 #if BSLS_PLATFORM_CMP_VERSION >= 1911
1657 #define BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE 1
1658
1659 #if BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
1660 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_MAYBE_UNUSED 1
1661 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NODISCARD 1
1662
1663 #if !defined(BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS)
1664 #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS 1
1665 #endif // feature test macro may have already defined this
1666 #endif // at least C++17
1667 #endif // at least Microsoft Visual Studio 2017, toolset version 14.11
1668
1669 // MS Visual Studio 2017 Update 5, toolset version 14.12
1670 #if BSLS_PLATFORM_CMP_VERSION >= 1912
1671 #if BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
1672 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES
1673 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE
1674 #endif // at least C++17
1675 #endif // at least Microsoft Visual Studio 2017, toolset version 14.12
1676
1677 #if BSLS_PLATFORM_CMP_VERSION >= 1910 && BSLS_PLATFORM_CMP_VERSION < 1920
1678 // MSVC2017 crashes when building bsl_deque.h with CTAD enabled.
1679 #ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1680 #undef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1681 #endif
1682 #endif // some Microsoft Visual Studio 2017, toolset < 14.20
1683
1684 // Microsoft Visual Studio doesn't follow WG14 N2322 Recommended practice yet
1685 // #define BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST
1686#endif // Microsoft Visual Studio
1687
1688// ============================================================================
1689// IBM Visual Age / xlC
1690// ============================================================================
1691
1692#if defined(BSLS_PLATFORM_CMP_IBM)
1693// IBM Visual Age xlC 11.1 and better include increasing support for C++11
1694// http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_ref/macros_lang_levels.html
1695// http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_ref/opt_langlvl.html
1696// xlC_r -qlanglvl=extended (include next, extern template, noreturn)
1697// xlC_r -qlanglvl=extended0x (additional features)
1698
1699 #if defined(__IBMCPP_CONSTEXPR)
1700 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR 1
1701 #endif
1702
1703 #if defined(__IBMCPP_DECLTYPE)
1704 #define BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE 1
1705 #endif
1706
1707 #if defined(__IBMCPP_DEFAULTED_AND_DELETED_FUNCTIONS)
1708 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS 1
1709 #define BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS 1
1710 #endif
1711
1712 #if defined(__IBMCPP_EXPLICIT)
1713 #define BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT 1
1714 #endif
1715
1716 #if defined(__IBMCPP_EXTERN_TEMPLATE)
1717 #define BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE 1
1718 #endif
1719
1720 #if defined(__IBM_INCLUDE_NEXT)
1721 #define BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT 1
1722 #endif
1723
1724 #if defined(__IBMCPP_INLINE_NAMESPACE)
1725 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE 1
1726 #endif
1727
1728 #if defined(__IBMCPP_NULLPTR)
1729 #define BSLS_COMPILERFEATURES_SUPPORT_NULLPTR 1
1730 #endif
1731
1732 #if defined(__IBMCPP_OVERRIDE)
1733 #define BSLS_COMPILERFEATURES_SUPPORT_FINAL 1
1734 #define BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE 1
1735 #endif
1736
1737 #if defined(__IBMCPP_RVALUE_REFERENCES)
1738 #define BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS 1
1739 #define BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES 1
1740 #endif
1741
1742 #if defined(__IBMCPP_STATIC_ASSERT)
1743 #define BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT 1
1744 #endif
1745
1746 #if defined(__IBMCPP_VARIADIC_TEMPLATES)
1747 #define BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES 1
1748 #endif
1749
1750 #if defined(__IBMC_NORETURN)
1751 // xlC has '_Noreturn', not the standard attribute
1752 //#define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN
1753 #endif
1754
1755 #if defined(__C99_HEX_FLOAT_CONST)
1756 // Unfortunately xlC does not compile hexadecimal floating point literals
1757 // properly (at least for the 'double' type that we use most). Denormal
1758 // values smaller than '0x0.8000000000000p-1022' are compiled to zero.
1759 // Hence we undefine this macro unless the compiler is updated (from
1760 // version 0x1001 where the bug was observed).
1761 #if BSLS_PLATFORM_CMP_VERSION <= 0x1001
1762 #ifdef BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1763 #undef BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1764 #endif
1765 #elif !defined(BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS)
1766 // The test driver verifies if the offending hexfloat literals now
1767 // compile to their propers values on this newer compiler version. If
1768 // not update the version check above to include this version as well.
1769 #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS 1
1770 #endif // standard feature test macro may have already defined this
1771 #endif
1772
1773 // (not yet supported in xlC)
1774 //https://www.ibm.com/support/knowledgecenter/SSGH3R_16.1.0/com.ibm.xlcpp161.aix.doc/language_ref/cpp11_support.html
1775 //
1776 // #define BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
1777 // #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14
1778 // #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17
1779 // #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT
1780 // #define BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS
1781
1782 // Not yet tested for support
1783 //
1784 // #define? BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS
1785 // #define? BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
1786
1787 // Not yet enabling C++17 support, but pro-active test drivers may want to
1788 // add coverage.
1789 //
1790 // #define BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE
1791 // #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES
1792 // #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE
1793
1794 // IBM Visual Age Suite does not yet follow WG14 N2322 Recommended practice
1795 // #define BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST
1796#endif // IBM Visual Age Suite
1797
1798// ============================================================================
1799// Oracle Developer Studio / CC
1800// ============================================================================
1801
1802#if defined(BSLS_PLATFORM_CMP_SUN)
1803// Oracle Developer Studio 12.4 claims C++11 support except for C++11
1804// concurrency and atomic operations, and for user-defined literals
1805// http://docs.oracle.com/cd/E37069_01/html/E37071/gncix.html#scrolltoc
1806// No C++11 features are available by default. To use any C++11 features, you
1807// must use the -std=c++11 option with the CC compiler.
1808// ('__cplusplus >= 201103L' when Oracle Solaris Studio 'CC -std=c++11' is
1809// invoked)
1810
1811 // CC -std=c++11 or later
1812 #if __cplusplus >= 201103L
1813
1814 // Oracle Developer Studio 12.4 (CC version 5.13) or newer
1815 #if BSLS_PLATFORM_CMP_VERSION >= 0x5130
1816 #define BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES 1
1817 #define BSLS_COMPILERFEATURES_SUPPORT_ATTRIBUTE_NORETURN 1
1818 #define BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE 1
1819 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS 1
1820 #define BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS 1
1821 #define BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS 1
1822 #define BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE 1
1823 #define BSLS_COMPILERFEATURES_SUPPORT_FINAL 1
1824 #define BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE 1
1825 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT 1
1826 #define BSLS_COMPILERFEATURES_SUPPORT_NULLPTR 1
1827 #define BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT 1
1828 #define BSLS_COMPILERFEATURES_SUPPORT_OVERRIDE 1
1829 #define BSLS_COMPILERFEATURES_SUPPORT_RAW_STRINGS 1
1830 #define BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT 1
1831 #endif // at least version 5.13
1832
1833 // Oracle Developer Studio 12.5 (CC version 5.14) or newer
1834 #if BSLS_PLATFORM_CMP_VERSION >= 0x5140
1835 #define BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS 1
1836 // CC 12.4 will overly aggressively match an initializer list when it
1837 // sees brace initialization, leading to rejection of valid code when
1838 // there is no valid initializer list conversion, but another method
1839 // creating a temporary object from the braced arguments should have
1840 // been chosen.
1841
1842 #define BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS 1
1843 // Although this feature might be available in an earlier compiler, we
1844 // are asking for trouble if we don't keep this feature together with
1845 // rvalue references.
1846
1847 #define BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES 1
1848 // CC 12.4 hits an awkward bug when performing deduction in some corner
1849 // cases, which happen to be important to our vector implementation.
1850
1851 #define BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER 1
1852 // The previous compiler ships with a mostly-complete version of the
1853 // <type_traits> header, but we insist on a full implementation before
1854 // defining this macro.
1855
1856 #define BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES 1
1857 // CC 12.4 has problems partially ordering template parameter packs
1858 // that typically result in failing to compile with ambiguity errors.
1859
1860 #define BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES 1
1861
1862 #define BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS 1
1863 // https://docs.oracle.com/cd/E60778_01/html/E60742/gkeza.html
1864 #endif // at least version 5.14
1865
1866 // Newer than Oracle Developer Studio 12.6 (CC version 5.15)
1867 #if BSLS_PLATFORM_CMP_VERSION >= 0x5150
1868 #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR 1
1869 // CC 12.4 'constexpr' implementation almost satisfies our testing, but
1870 // the compiler crashes when for some rare-but-reasonable data
1871 // structures. CC 12.5 has different corner cases, although we are
1872 // still trying to track down a narrowed test case. Both 12.5 and
1873 // 12.6 have a regression compared to 12.4 though with the (implicit)
1874 // 'constexpr' constructors of aggregates that have dependent base
1875 // classes, such as most type traits.
1876
1877 #define BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS 1
1878 // CC 12.4, CC 12.5, and 12.6 all fail in a very specific way, which,
1879 // unfortunately, breaks for 'shared_ptr' in a way that is widely used.
1880 // Note that the version check assumes the next revision of the
1881 // compiler will have this fix, or the test driver will force us to
1882 // update again.
1883 #endif // above version 5.15
1884
1885 // Not yet CC version 5.16 (Studio 12.7?)
1886 #if BSLS_PLATFORM_CMP_VERSION < 0x5160
1887 #define BSLS_COMPILERFEATURES_INITIALIZER_LIST_LEAKS_ON_EXCEPTIONS 1
1888 #endif // below version 5.16
1889 #endif // C++11 or later
1890
1891 // No C++14 features are available by default. To use any C++14 features,
1892 // you must use the -std=c++14 option with the CC compiler.
1893 // '__cplusplus >= 201402L' when Oracle Solaris Studio 'CC -std=c++14' is
1894 // invoked.
1895
1896 //CC -std=c++14
1897 #if __cplusplus >= 201402L
1898 // Newer than Oracle Developer Studio 12.6 (CC version 5.15)
1899 #if BSLS_PLATFORM_CMP_VERSION > 0x5150
1900 #define BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES 1
1901 #endif // above version 5.15
1902 #endif // C++14 or later
1903
1904 // No constexpr support
1905 // #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14
1906 // #define BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP17
1907
1908 // No '__include_next'
1909 // #define BSLS_COMPILERFEATURES_SUPPORT_INCLUDE_NEXT
1910
1911 // No C++17 features
1912 // #define BSLS_COMPILERFEATURES_SUPPORT_HAS_INCLUDE
1913 // #define BSLS_COMPILERFEATURES_SUPPORT_HEXFLOAT_LITERALS
1914 // #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE
1915
1916 // Oracle Solaris Studio does not yet follow WG14 N2322 Recommended practice
1917 // #define BSLS_COMPILERFEATURES_PP_LINE_IS_ON_FIRST
1918#endif // Oracle Developer Studio
1919
1920// ============================================================================
1921// DEPRECATED ALIASES
1922// ============================================================================
1923
1924#ifdef BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_IN_FNC_TYPE
1925 #define BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT_TYPES 1
1926#endif
1927
1928// ============================================================================
1929// STANDARD FEATURE-DETECTION MACROS
1930// ============================================================================
1931
1932#if defined(__cpp_lib_is_constant_evaluated)
1933 #define BSLS_COMPILERFEATURES_SUPPORT_IS_CONSTANT_EVALUATED 1
1934#endif
1935
1936// ============================================================================
1937// DISABLE FEATURES REMOVED BY LATER STANDARDS
1938// ============================================================================
1939
1940// Undefine macros defined for earlier dialects (including C++98) that are
1941// removed from later editions of the C++ Standard.
1942
1943#if BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
1944 #undef BSLS_COMPILERFEATURES_SUPPORT_THROW_SPECIFICATIONS
1945#endif
1946
1947// ============================================================================
1948// ENFORCE FEATURE INTERACTIONS
1949// ============================================================================
1950
1951#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \
1952 !defined(BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES)
1953
1954 #undef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1955 // BDE move-emulation for C++03 requires support for alias templates in
1956 // order to provide a transparent upgrade to the C++11 syntax that also
1957 // supports implicit-move from rvalues.
1958#endif
1959
1960// ============================================================================
1961// SIMULATE VARIOUS C++11 FEATURES
1962// ============================================================================
1963
1964#if !defined(BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES)
1965
1966 #define BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES 1
1967
1968 #ifndef BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1969 #define BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES 1
1970 #endif
1971
1972 #if defined(__cplusplus) && BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1973
1974 #define BSLS_COMPILERFEATURES_NILT BloombergLP::bsls::CompilerFeaturesNilT
1975
1976 #define BSLS_COMPILERFEATURES_NILV BloombergLP::bsls::CompilerFeaturesNilV
1977
1978 #define BSLS_COMPILERFEATURES_NILTR(n) BSLS_COMPILERFEATURES_NILT,
1979
1980 #define BSLS_COMPILERFEATURES_FILLT(n) \
1981 BSLS_MACROREPEAT(n, BSLS_COMPILERFEATURES_NILTR) \
1982 BSLS_COMPILERFEATURES_NILT
1983
1984 #define BSLS_COMPILERFEATURES_NILVR(n) BSLS_COMPILERFEATURES_NILV,
1985
1986 #define BSLS_COMPILERFEATURES_FILLV(n) \
1987 BSLS_MACROREPEAT(n,BSLS_COMPILERFEATURES_NILVR) \
1988 BSLS_COMPILERFEATURES_NILV
1989
1990
1991namespace bsls {
1992
1993enum CompilerFeaturesNilT { COMPILERFEATURESNILV = 0x7fff6f76 };
1994
1995} // close package namespace
1996
1997
1998 #endif // C++ and BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES == 1
1999#endif // ! BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES
2000
2001#ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
2002 #define BSLS_COMPILERFEATURES_SIMULATE_FORWARD_WORKAROUND 1
2003
2004 #ifndef BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2005 #define BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES 1
2006 #endif
2007#endif
2008
2009#ifdef BSLS_COMPILERFEATURES_SIMULATE_FORWARD_WORKAROUND
2010 // Use a work-around for the absence of perfect-forwarding.
2011
2012 #define BSLS_COMPILERFEATURES_FORWARD_REF(T) const T&
2013 // On compilers that support C++11 perfect forwarding, replace with 'T&&',
2014 // i.e., an argument that can be perfect-forwarded; otherwise, replace with
2015 // 'const T&', the classic way to accept arguments of unknown
2016 // rvalue/lvalue-ness.
2017
2018 #define BSLS_COMPILERFEATURES_FORWARD(T,V) \
2019 ::BloombergLP::bslmf::Util::forward(V)
2020 // On compilers that support C++11 perfect forwarding, replace with
2021 // 'bsl::forward<T>(V)', i.e., use perfect-forwarding; otherwise, replace
2022 // with '(V)', the classic way to forward arguments safely.
2023
2024#else // !defined simulate forwarding
2025
2026 // Use real perfect-forwarding; no workaround needed. Note that the explicit
2027 // 'BloombergLP' qualification is needed for 'bsls::Util' when it is used
2028 // from within namespace 'bsl', the BDE standard library implementation.
2029
2030 #define BSLS_COMPILERFEATURES_FORWARD_REF(T) T&&
2031
2032 #define BSLS_COMPILERFEATURES_FORWARD(T,V) \
2033 ::BloombergLP::bsls::Util::forward<T>(V)
2034
2035#endif // forward-workaround for simulation
2036
2037#endif // header guard
2038
2039// ----------------------------------------------------------------------------
2040// Copyright 2020 Bloomberg Finance L.P.
2041//
2042// Licensed under the Apache License, Version 2.0 (the "License");
2043// you may not use this file except in compliance with the License.
2044// You may obtain a copy of the License at
2045//
2046// http://www.apache.org/licenses/LICENSE-2.0
2047//
2048// Unless required by applicable law or agreed to in writing, software
2049// distributed under the License is distributed on an "AS IS" BASIS,
2050// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2051// See the License for the specific language governing permissions and
2052// limitations under the License.
2053// ----------------------------- END-OF-FILE ----------------------------------
2054
2055/** @} */
2056/** @} */
2057/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_PLATFORM_COMPILER_ERROR
Definition bsls_platform.h:289
Definition bdlt_iso8601util.h:691