From 427b53405442872decb69d9735db0fa64106ebe2 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 15 Jun 2021 06:48:00 -0700 Subject: [PATCH] Add no_value state to value --- include/fmt/core.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 9e86afc4..0531b37f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -328,7 +328,9 @@ using remove_cvref_t = typename std::remove_cv>::type; template struct type_identity { using type = T; }; template using type_identity_t = typename type_identity::type; -struct monostate {}; +struct monostate { + constexpr monostate() {} +}; // An enable_if helper to be used in template parameters which results in much // shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed @@ -1131,6 +1133,7 @@ template class value { using char_type = typename Context::char_type; union { + monostate no_value; int int_value; unsigned uint_value; long long long_long_value; @@ -1148,7 +1151,8 @@ template class value { named_arg_value named_args; }; - constexpr FMT_INLINE value(int val = 0) : int_value(val) {} + constexpr FMT_INLINE value() : no_value() {} + constexpr FMT_INLINE value(int val) : int_value(val) {} constexpr FMT_INLINE value(unsigned val) : uint_value(val) {} constexpr FMT_INLINE value(long long val) : long_long_value(val) {} constexpr FMT_INLINE value(unsigned long long val) : ulong_long_value(val) {}