Main docs: Home
Macros | |
| #define | PW_CONSTEXPR_CPP20 constexpr |
| #define | PW_CONSTEVAL constexpr |
| #define | PW_CONSTINIT |
| #define | PW_NODISCARD_STR(str) [[nodiscard(str)]] |
| #define | PW_CXX_STANDARD_IS_SUPPORTED(std) (__cplusplus >= _PW_CXX_STANDARD_##std()) |
| #define | PW_C_STANDARD_IS_SUPPORTED(std) (0 >= _PW_C_STANDARD_##std()) |
| #define PW_C_STANDARD_IS_SUPPORTED | ( | std | ) | (0 >= _PW_C_STANDARD_##std()) |
Evaluates true if the provided C standard (89, 98, 11, 17, 23) is supported by the compiler. This is a simple alternative to checking the value of the __STDC_VERSION__ macro.
| #define PW_CONSTEVAL constexpr |
Mark functions as consteval if supported (C++20), or constexpr if not (C++17).
Use with caution in portable code. Calling a consteval function outside of a constant expression is an error.
| #define PW_CONSTEXPR_CPP20 constexpr |
Mark functions as constexpr if compiling for C++20 or newer. In C++17, PW_CONSTEXPR_CPP20 expands to nothing.
This is primarily used for functions that rely on standard library functions that only became constexpr in C++20 (e.g. std::copy). Use with caution in portable code; if constexpr is required in C++17, use constexpr.
| #define PW_CONSTINIT |
Declare a variable as constinit. Requires compiler-specific features if constinit is not available.
| #define PW_CXX_STANDARD_IS_SUPPORTED | ( | std | ) | (__cplusplus >= _PW_CXX_STANDARD_##std()) |
Evaluates true if the provided C++ standard (98, 11, 14, 17, 20, 23) is supported by the compiler. This is a simple alternative to checking the value of the __cplusplus macro.
| #define PW_NODISCARD_STR | ( | str | ) | [[nodiscard(str)]] |
Provides [[nodiscard]] with a string literal description, which is only available starting in C++20.