From b2d3a86ec0865c2771191d674e85d31d22d5b1da Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 26 Feb 2020 06:26:46 -0800 Subject: [PATCH] Make FMT_ASSERT work in constexpr on clang 4.0.1 --- include/fmt/core.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 1bb58793..76fedf05 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -259,9 +259,9 @@ FMT_API void assert_fail(const char* file, int line, const char* message); # ifdef NDEBUG # define FMT_ASSERT(condition, message) # else -# define FMT_ASSERT(condition, message) \ - ((condition) \ - ? void() \ +# define FMT_ASSERT(condition, message) \ + ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ + ? (void)0 \ : ::fmt::internal::assert_fail(__FILE__, __LINE__, (message))) # endif #endif @@ -947,12 +947,10 @@ template struct arg_mapper { map(static_cast::type>(val))) { return map(static_cast::type>(val)); } - template < - typename T, - FMT_ENABLE_IF( - !is_string::value && !is_char::value && - (has_formatter::value || - has_fallback_formatter::value))> + template ::value && !is_char::value && + (has_formatter::value || + has_fallback_formatter::value))> FMT_CONSTEXPR const T& map(const T& val) { return val; }