@@ -390,8 +390,9 @@ regarding RAII.
390
390
@brief C++14 constexpr
391
391
@m_since{2020,06}
392
392
393
- Expands to @cpp constexpr @ce on C++14 and newer, empty on C++11. Useful for
394
- selectively marking functions that make use of C++14 relaxed constexpr rules.
393
+ Expands to @cpp constexpr @ce on compilers supporting C++14 relaxed constexpr
394
+ rules. This includes all that fully implement the standard but excludes
395
+ partial implementations such as MSVC 2015 or GCC 4.8.
395
396
@see @ref CORRADE_CXX_STANDARD
396
397
*/
397
398
#if (defined __cpp_constexpr && __cpp_constexpr >= 201304) || \
@@ -401,6 +402,20 @@ selectively marking functions that make use of C++14 relaxed constexpr rules.
401
402
#define CORRADE_CONSTEXPR14
402
403
#endif
403
404
405
+ /* * @hideinitializer
406
+ @brief C++20 is_constant_evaluated
407
+ @m_since{2022,10}
408
+
409
+ Expands to a predicate determining whether given @cpp constexpr @ce function
410
+ is being evaluated at compile-time or not. Under C++14 rules, constexpr
411
+ functions may be defined as long as at least some of the code paths are able
412
+ to be executed at compile-time. As long as a fallback is present, features
413
+ such as SIMD or inline assembly may be used in functions marked constexpr.
414
+
415
+ This support is available on all C++20 capable compilers, but also certain
416
+ ones (Clang 9, GCC 9, MSVC 17.1) that expose the feature as a non-portable
417
+ extension. In which case it may be used under C++14 relaxed constexpr rules.
418
+ */
404
419
#if (defined(__clang__) && __clang_major__ >= 9) || (defined(__GNUG__) && __GNUG__ >= 9) || (defined(_MSC_VER) && _MSC_VER >= 1931)
405
420
#define CORRADE_CONSTEVAL (__builtin_is_constant_evaluated())
406
421
#elif CORRADE_CXX_STANDARD >= 202002
0 commit comments