From c09ffd81c9332303234c9374ab1bd180fefb58ee Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 22 Nov 2023 09:46:04 -0800 Subject: [PATCH] Remove this-> from decltype (#3723) * Remove this-> from decltype The latest version of MSVC doesn't like it, and removing it doesn't seem to harm anything. * Add ifdef for GCC < 5 --- include/fmt/core.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 18ebada216f0..aaeb2cfa81e5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -244,6 +244,15 @@ # endif #endif +// GCC < 5 requires this-> in decltype +#ifndef FMT_DECLTYPE_THIS +# if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 +# define FMT_DECLTYPE_THIS this-> +# else +# define FMT_DECLTYPE_THIS +# endif +#endif + // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") #if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) && !defined(__LCC__) && \ @@ -1439,7 +1448,7 @@ template struct arg_mapper { // Only map owning types because mapping views can be unsafe. template , FMT_ENABLE_IF(std::is_arithmetic::value)> - FMT_CONSTEXPR FMT_INLINE auto map(const T& val) -> decltype(this->map(U())) { + FMT_CONSTEXPR FMT_INLINE auto map(const T& val) -> decltype(FMT_DECLTYPE_THIS map(U())) { return map(format_as(val)); } @@ -1463,13 +1472,13 @@ template struct arg_mapper { !is_string::value && !is_char::value && !is_named_arg::value && !std::is_arithmetic>::value)> - FMT_CONSTEXPR FMT_INLINE auto map(T& val) -> decltype(this->do_map(val)) { + FMT_CONSTEXPR FMT_INLINE auto map(T& val) -> decltype(FMT_DECLTYPE_THIS do_map(val)) { return do_map(val); } template ::value)> FMT_CONSTEXPR FMT_INLINE auto map(const T& named_arg) - -> decltype(this->map(named_arg.value)) { + -> decltype(FMT_DECLTYPE_THIS map(named_arg.value)) { return map(named_arg.value); }