diff --git a/include/fmt/core.h b/include/fmt/core.h index 7a654e2b86d2..2625d86bf37b 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -73,7 +73,8 @@ # endif #endif -#if FMT_HAS_FEATURE(cxx_explicit_conversions) +#if FMT_HAS_FEATURE(cxx_explicit_conversions) || \ + FMT_MSC_VER >= 1800 # define FMT_EXPLICIT explicit #else # define FMT_EXPLICIT @@ -970,8 +971,17 @@ class format_arg_store { friend class basic_format_args; + static FMT_CONSTEXPR uint64_t get_types() { + return IS_PACKED ? internal::get_types() + : -static_cast(NUM_ARGS); + } + public: +#if FMT_USE_CONSTEXPR + static constexpr uint64_t TYPES = get_types(); +#else static const uint64_t TYPES; +#endif #if FMT_GCC_VERSION && FMT_GCC_VERSION <= 405 // Workaround an array initialization bug in gcc 4.5 and earlier. @@ -984,10 +994,10 @@ class format_arg_store { #endif }; +#if !FMT_USE_CONSTEXPR template -const uint64_t format_arg_store::TYPES = IS_PACKED ? - internal::get_types() : - -static_cast(NUM_ARGS); +const uint64_t format_arg_store::TYPES = get_types(); +#endif /** \rst diff --git a/include/fmt/format.h b/include/fmt/format.h index e9c16b1f3105..3d35a18c5627 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1381,13 +1381,13 @@ class float_type_checker : private ErrorHandler { } }; -template +template class char_specs_checker : public ErrorHandler { private: - char type_; + CharType type_; public: - FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh) + FMT_CONSTEXPR char_specs_checker(CharType type, ErrorHandler eh) : ErrorHandler(eh), type_(type) {} FMT_CONSTEXPR void on_int() { @@ -3110,8 +3110,10 @@ struct formatter< type_spec, internal::int_type_checker(eh)); break; case internal::char_type: - handle_char_specs(specs_, internal::char_specs_checker( - type_spec, eh)); + handle_char_specs( + specs_, + internal::char_specs_checker( + type_spec, eh)); break; case internal::double_type: case internal::long_double_type: