From c83a5d42bb65cc7f273ba93712586ec82a0a2157 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 29 May 2022 15:01:43 -0700 Subject: [PATCH] FMT_MSC_VER -> FMT_MSC_VERSION --- include/fmt/chrono.h | 9 ++++----- include/fmt/core.h | 26 +++++++++++++------------- include/fmt/format-inl.h | 2 +- include/fmt/format.h | 17 +++++++++-------- include/fmt/ostream.h | 2 +- include/fmt/ranges.h | 10 +++++----- test/core-test.cc | 8 ++++---- test/format-test.cc | 2 +- test/ranges-test.cc | 4 ++-- test/xchar-test.cc | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 82874e4a..c3c52bf5 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -345,7 +345,7 @@ auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc) if (detail::is_utf8() && loc != get_classic_locale()) { // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and // gcc-4. -#if FMT_MSC_VER != 0 || \ +#if FMT_MSC_VERSION != 0 || \ (defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI)) // The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5 // and newer. @@ -469,7 +469,7 @@ inline std::tm localtime(std::time_t time) { bool fallback(int res) { return res == 0; } -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION bool fallback(detail::null<>) { using namespace fmt::detail; std::tm* tm = std::localtime(&time_); @@ -515,7 +515,7 @@ inline std::tm gmtime(std::time_t time) { bool fallback(int res) { return res == 0; } -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION bool fallback(detail::null<>) { std::tm* tm = std::gmtime(&time_); if (tm) tm_ = *tm; @@ -1466,8 +1466,7 @@ inline std::chrono::duration get_milliseconds( // C++20 spec. If more than 18 fractional digits are required then returns 6 for // microseconds precision. template () / 10)> + bool Enabled = (N < 19) && (Num <= max_value() / 10)> struct count_fractional_digits { static constexpr int value = Num % Den == 0 ? N : count_fractional_digits::value; diff --git a/include/fmt/core.h b/include/fmt/core.h index 7cb37787..48a32383 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -50,10 +50,10 @@ #endif #ifdef _MSC_VER -# define FMT_MSC_VER _MSC_VER +# define FMT_MSC_VERSION _MSC_VER # define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) #else -# define FMT_MSC_VER 0 +# define FMT_MSC_VERSION 0 # define FMT_MSC_WARNING(...) #endif @@ -70,7 +70,7 @@ #endif #if (defined(__has_include) || FMT_ICC_VERSION >= 1600 || \ - FMT_MSC_VER > 1900) && \ + FMT_MSC_VERSION > 1900) && \ !defined(__INTELLISENSE__) # define FMT_HAS_INCLUDE(x) __has_include(x) #else @@ -92,8 +92,8 @@ // Check if relaxed C++14 constexpr is supported. // GCC doesn't allow throw in constexpr until version 6 (bug 67371). #ifndef FMT_USE_CONSTEXPR -# if (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1912 || \ - (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ +# if (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VERSION >= 1912 || \ + (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ !FMT_ICC_VERSION && !defined(__NVCC__) # define FMT_USE_CONSTEXPR 1 # else @@ -125,7 +125,7 @@ #elif defined(_LIBCPP_VERSION) && __cplusplus >= 201703L && \ _LIBCPP_VERSION >= 4000 # define FMT_CONSTEXPR_CHAR_TRAITS constexpr -#elif FMT_MSC_VER >= 1914 && _MSVC_LANG >= 201703L +#elif FMT_MSC_VERSION >= 1914 && FMT_CPLUSPLUS >= 201703L # define FMT_CONSTEXPR_CHAR_TRAITS constexpr #endif #ifndef FMT_CONSTEXPR_CHAR_TRAITS @@ -135,7 +135,7 @@ // Check if exceptions are disabled. #ifndef FMT_EXCEPTIONS # if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ - FMT_MSC_VER && !_HAS_EXCEPTIONS + FMT_MSC_VERSION && !_HAS_EXCEPTIONS # define FMT_EXCEPTIONS 0 # else # define FMT_EXCEPTIONS 1 @@ -144,7 +144,7 @@ // [[noreturn]] is disabled on MSVC and NVCC because of bogus unreachable code // warnings. -#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VER && \ +#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \ !defined(__NVCC__) # define FMT_NORETURN [[noreturn]] #else @@ -249,14 +249,14 @@ #endif #ifndef FMT_UNICODE -# define FMT_UNICODE !FMT_MSC_VER +# define FMT_UNICODE !FMT_MSC_VERSION #endif #ifndef FMT_CONSTEVAL # if ((FMT_GCC_VERSION >= 1000 || FMT_CLANG_VERSION >= 1101) && \ __cplusplus > 201703L && !defined(__apple_build_version__)) || \ (defined(__cpp_consteval) && \ - (!FMT_MSC_VER || _MSC_FULL_VER >= 193030704)) + (!FMT_MSC_VERSION || _MSC_FULL_VER >= 193030704)) // consteval is broken in MSVC before VS2022 and Apple clang 13. # define FMT_CONSTEVAL consteval # define FMT_HAS_CONSTEVAL @@ -364,7 +364,7 @@ template struct std_string_view {}; #ifdef FMT_USE_INT128 // Do nothing. #elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \ - !(FMT_CLANG_VERSION && FMT_MSC_VER) + !(FMT_CLANG_VERSION && FMT_MSC_VERSION) # define FMT_USE_INT128 1 using int128_opt = __int128_t; // An optional native 128-bit integer. using uint128_opt = __uint128_t; @@ -1416,8 +1416,8 @@ template struct arg_mapper { !std::is_const>::value || has_fallback_formatter::value> {}; -#if (FMT_MSC_VER != 0 && FMT_MSC_VER < 1910) || FMT_ICC_VERSION != 0 || \ - defined(__NVCC__) +#if (FMT_MSC_VERSION != 0 && FMT_MSC_VERSION < 1910) || \ + FMT_ICC_VERSION != 0 || defined(__NVCC__) // Workaround a bug in MSVC and Intel (Issue 2746). template FMT_CONSTEXPR FMT_INLINE auto do_map(T&& val) -> T& { return val; diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 5e4950e2..19f64c3f 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -116,7 +116,7 @@ template FMT_FUNC Char decimal_point_impl(locale_ref) { #endif } // namespace detail -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION FMT_API FMT_FUNC format_error::~format_error() noexcept = default; #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index 7cb0e75e..9434efab 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -71,7 +71,7 @@ # define FMT_NOINLINE #endif -#if FMT_MSC_VER +#if FMT_MSC_VERSION # define FMT_MSC_DEFAULT = default #else # define FMT_MSC_DEFAULT @@ -79,7 +79,7 @@ #ifndef FMT_THROW # if FMT_EXCEPTIONS -# if FMT_MSC_VER || defined(__NVCC__) +# if FMT_MSC_VERSION || defined(__NVCC__) FMT_BEGIN_NAMESPACE namespace detail { template inline void do_throw(const Exception& x) { @@ -119,12 +119,12 @@ FMT_END_NAMESPACE #endif #ifndef FMT_DEPRECATED -# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VER >= 1900 +# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900 # define FMT_DEPRECATED [[deprecated]] # else # if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__) # define FMT_DEPRECATED __attribute__((deprecated)) -# elif FMT_MSC_VER +# elif FMT_MSC_VERSION # define FMT_DEPRECATED __declspec(deprecated) # else # define FMT_DEPRECATED /* deprecated */ @@ -135,7 +135,7 @@ FMT_END_NAMESPACE #ifndef FMT_USE_USER_DEFINED_LITERALS // EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs. # if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \ - FMT_MSC_VER >= 1900) && \ + FMT_MSC_VERSION >= 1900) && \ (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480) # define FMT_USE_USER_DEFINED_LITERALS 1 # else @@ -153,7 +153,7 @@ FMT_END_NAMESPACE // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519. -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION # if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION # define FMT_BUILTIN_CLZ(n) __builtin_clz(n) # endif @@ -175,14 +175,15 @@ FMT_END_NAMESPACE # endif #endif -#if FMT_MSC_VER +#if FMT_MSC_VERSION # include // _BitScanReverse[64], _BitScanForward[64], _umul128 #endif // Some compilers masquerade as both MSVC and GCC-likes or otherwise support // __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the // MSVC intrinsics if the clz and clzll builtins are not available. -#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(FMT_BUILTIN_CTZLL) +#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL) && \ + !defined(FMT_BUILTIN_CTZLL) FMT_BEGIN_NAMESPACE namespace detail { // Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning. diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index a03b0a23..9b870820 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -93,7 +93,7 @@ inline bool write(std::wfilebuf&, fmt::basic_string_view) { // It is a separate function rather than a part of vprint to simplify testing. template void write_buffer(std::basic_ostream& os, buffer& buf) { - if (const_check(FMT_MSC_VER)) { + if (const_check(FMT_MSC_VERSION)) { auto filebuf = dynamic_cast*>(os.rdbuf()); if (filebuf && write(*filebuf, {buf.data(), buf.size()})) return; } diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 5d1461b6..62a3cdc1 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -94,7 +94,7 @@ template struct conditional_helper {}; template struct is_range_ : std::false_type {}; -#if !FMT_MSC_VER || FMT_MSC_VER > 1800 +#if !FMT_MSC_VERSION || FMT_MSC_VERSION > 1800 # define FMT_DECLTYPE_RETURN(val) \ ->decltype(val) { return val; } \ @@ -179,7 +179,7 @@ template class is_tuple_like_ { }; // Check for integer_sequence -#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900 +#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VERSION >= 1900 template using integer_sequence = std::integer_sequence; template using index_sequence = std::index_sequence; @@ -221,7 +221,7 @@ template void for_each(Tuple&& tup, F&& f) { for_each(indexes, std::forward(tup), std::forward(f)); } -#if FMT_MSC_VER +#if FMT_MSC_VERSION // Older MSVC doesn't get the reference type correctly for arrays. template struct range_reference_type_impl { using type = decltype(*detail::range_begin(std::declval())); @@ -358,7 +358,7 @@ struct formatter< enable_if_t< fmt::is_range::value // Workaround a bug in MSVC 2019 and earlier. -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION && (is_formattable>, Char>::value || @@ -419,7 +419,7 @@ struct formatter< T, Char, enable_if_t::value // Workaround a bug in MSVC 2019 and earlier. -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION && (is_formattable, Char>::value || detail::has_fallback_formatter, Char>::value) diff --git a/test/core-test.cc b/test/core-test.cc index 8692c76b..c7f07273 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -128,7 +128,7 @@ TEST(core_test, buffer_appender) { #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 470 TEST(buffer_test, noncopyable) { EXPECT_FALSE(std::is_copy_constructible>::value); -# if !FMT_MSC_VER +# if !FMT_MSC_VERSION // std::is_copy_assignable is broken in MSVC2013. EXPECT_FALSE(std::is_copy_assignable>::value); # endif @@ -136,7 +136,7 @@ TEST(buffer_test, noncopyable) { TEST(buffer_test, nonmoveable) { EXPECT_FALSE(std::is_move_constructible>::value); -# if !FMT_MSC_VER +# if !FMT_MSC_VERSION // std::is_move_assignable is broken in MSVC2013. EXPECT_FALSE(std::is_move_assignable>::value); # endif @@ -804,7 +804,7 @@ TEST(core_test, is_formattable) { static_assert(fmt::is_formattable::value, ""); static_assert(fmt::is_formattable::value, ""); -#if !FMT_MSC_VER || FMT_MSC_VER >= 1910 +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1910 static_assert(!fmt::is_formattable::value, ""); #endif @@ -896,7 +896,7 @@ TEST(core_test, format_implicitly_convertible_to_string_view) { } // std::is_constructible is broken in MSVC until version 2015. -#if !FMT_MSC_VER || FMT_MSC_VER >= 1900 +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1900 struct explicitly_convertible_to_string_view { explicit operator fmt::string_view() const { return "foo"; } }; diff --git a/test/format-test.cc b/test/format-test.cc index 7a859838..542761b6 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2150,7 +2150,7 @@ TEST(format_test, format_string_errors) { EXPECT_ERROR_NOARGS("foo", nullptr); EXPECT_ERROR_NOARGS("}", "unmatched '}' in format string"); EXPECT_ERROR("{0:s", "unknown format specifier", date); -# if !FMT_MSC_VER || FMT_MSC_VER >= 1916 +# if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1916 // This causes an detail compiler error in MSVC2017. EXPECT_ERROR("{:{<}", "invalid fill character '{'", int); EXPECT_ERROR("{:10000000000}", "number is too big", int); diff --git a/test/ranges-test.cc b/test/ranges-test.cc index c4a77124..cdc6930d 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -21,7 +21,7 @@ # define FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY #endif -#if !FMT_MSC_VER || FMT_MSC_VER > 1910 +#if !FMT_MSC_VERSION || FMT_MSC_VERSION > 1910 # define FMT_RANGES_TEST_ENABLE_JOIN # define FMT_RANGES_TEST_ENABLE_FORMAT_STRUCT #endif @@ -219,7 +219,7 @@ TEST(ranges_test, enum_range) { EXPECT_EQ(fmt::format("{}", v), "[0]"); } -#if !FMT_MSC_VER +#if !FMT_MSC_VERSION struct unformattable {}; TEST(ranges_test, unformattable_range) { diff --git a/test/xchar-test.cc b/test/xchar-test.cc index c695739b..7db35913 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -66,7 +66,7 @@ TYPED_TEST(is_string_test, is_string) { } // std::is_constructible is broken in MSVC until version 2015. -#if !FMT_MSC_VER || FMT_MSC_VER >= 1900 +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1900 struct explicitly_convertible_to_wstring_view { explicit operator fmt::wstring_view() const { return L"foo"; } };