Skip to content

Commit 8f81721

Browse files
committed
Utility: add docs for the two new macros
1 parent 6d68526 commit 8f81721

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Corrade/Utility/Macros.h

+17-2
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ regarding RAII.
390390
@brief C++14 constexpr
391391
@m_since{2020,06}
392392
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.
395396
@see @ref CORRADE_CXX_STANDARD
396397
*/
397398
#if (defined __cpp_constexpr && __cpp_constexpr >= 201304) || \
@@ -401,6 +402,20 @@ selectively marking functions that make use of C++14 relaxed constexpr rules.
401402
#define CORRADE_CONSTEXPR14
402403
#endif
403404

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+
*/
404419
#if (defined(__clang__) && __clang_major__ >= 9) || (defined(__GNUG__) && __GNUG__ >= 9) || (defined(_MSC_VER) && _MSC_VER >= 1931)
405420
#define CORRADE_CONSTEVAL (__builtin_is_constant_evaluated())
406421
#elif CORRADE_CXX_STANDARD >= 202002

0 commit comments

Comments
 (0)