From 5d48733596f4ee658dc46890c53e9370c94a76e4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 7 Jun 2019 19:27:20 -0700 Subject: [PATCH] Clean up value construction --- include/fmt/core.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index daed6e3d..342738c5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -687,34 +687,32 @@ template class value { long double long_double_value; const void* pointer; string_value string; - string_value sstring; - string_value ustring; custom_value custom; const named_arg_base* named_arg; }; FMT_CONSTEXPR value(int val = 0) : int_value(val) {} FMT_CONSTEXPR value(unsigned val) : uint_value(val) {} - value(long long val) { long_long_value = val; } - value(unsigned long long val) { ulong_long_value = val; } - value(double val) { double_value = val; } - value(long double val) { long_double_value = val; } + value(long long val) : long_long_value(val) {} + value(unsigned long long val) : ulong_long_value(val) {} + value(double val) : double_value(val) {} + value(long double val) : long_double_value(val) {} value(const char_type* val) { string.value = val; } value(const signed char* val) { static_assert(std::is_same::value, "incompatible string types"); - sstring.value = val; + string.value = reinterpret_cast(val); } value(const unsigned char* val) { static_assert(std::is_same::value, "incompatible string types"); - ustring.value = val; + string.value = reinterpret_cast(val); } value(basic_string_view val) { string.value = val.data(); string.size = val.size(); } - value(const void* val) { pointer = val; } + value(const void* val) : pointer(val) {} template explicit value(const T& val) { custom.value = &val; @@ -727,7 +725,7 @@ template class value { internal::fallback_formatter>>; } - value(const named_arg_base& arg) { named_arg = &arg; } + value(const named_arg_base& val) { named_arg = &val; } private: // Formats an argument of a custom type, such as a user-defined class.