Basics of formatting at compile-time based on compile-time API (#2019)

This commit is contained in:
Alexey Ochapov
2020-11-29 19:59:11 +03:00
committed by GitHub
parent 119f7dc3d6
commit dac753b81e
4 changed files with 137 additions and 34 deletions

View File

@@ -96,6 +96,12 @@
# define FMT_CONSTEXPR_DECL
#endif
#if __cplusplus >= 202002L
# define FMT_CONSTEXPR20 constexpr
#else
# define FMT_CONSTEXPR20 inline
#endif
#ifndef FMT_OVERRIDE
# if FMT_HAS_FEATURE(cxx_override_control) || \
(FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900
@@ -283,6 +289,14 @@ struct monostate {};
namespace detail {
constexpr bool is_constant_evaluated() FMT_DETECTED_NOEXCEPT {
#ifdef __cpp_lib_is_constant_evaluated
return std::is_constant_evaluated();
#else
return false;
#endif
}
// A helper function to suppress "conditional expression is constant" warnings.
template <typename T> constexpr T const_check(T value) { return value; }