diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 50d9ef48faf97..c09dd6f2a158d 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -14,7 +14,7 @@ FMT_BEGIN_NAMESPACE namespace detail { template -FMT_CONSTEXPR inline counting_iterator copy_str(InputIt begin, InputIt end, +inline counting_iterator copy_str(InputIt begin, InputIt end, counting_iterator it) { return it + (end - begin); } @@ -568,7 +568,7 @@ format_to_n_result format_to_n(OutputIt out, size_t n, template ::value)> -FMT_CONSTEXPR20 size_t formatted_size(const S& format_str, const Args&... args) { +size_t formatted_size(const S& format_str, const Args&... args) { return fmt::format_to(detail::counting_iterator(), format_str, args...) .count(); } diff --git a/include/fmt/format.h b/include/fmt/format.h index 047144cf46b3b..2768a037209e6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1231,7 +1231,7 @@ FMT_CONSTEXPR20 auto format_decimal(Char* out, UInt value, int size) template >::value)> -FMT_CONSTEXPR inline auto format_decimal(Iterator out, UInt value, int size) +inline auto format_decimal(Iterator out, UInt value, int size) -> format_decimal_result { // Buffer is large enough to hold all digits (digits10 + 1). Char buffer[digits10() + 1]; @@ -2137,29 +2137,29 @@ class counting_iterator { FMT_UNCHECKED_ITERATOR(counting_iterator); struct value_type { - template FMT_CONSTEXPR void operator=(const T&) {} + template void operator=(const T&) {} }; - FMT_CONSTEXPR counting_iterator() : count_(0) {} + counting_iterator() : count_(0) {} - FMT_CONSTEXPR size_t count() const { return count_; } + size_t count() const { return count_; } - FMT_CONSTEXPR counting_iterator& operator++() { + counting_iterator& operator++() { ++count_; return *this; } - FMT_CONSTEXPR counting_iterator operator++(int) { + counting_iterator operator++(int) { auto it = *this; ++*this; return it; } - FMT_CONSTEXPR friend counting_iterator operator+(counting_iterator it, difference_type n) { + friend counting_iterator operator+(counting_iterator it, difference_type n) { it.count_ += static_cast(n); return it; } - FMT_CONSTEXPR value_type operator*() const { return {}; } + value_type operator*() const { return {}; } }; template diff --git a/test/compile-test.cc b/test/compile-test.cc index 005c4993098b0..2a9e16196d01b 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -227,14 +227,10 @@ TEST(compile_test, format_to_n) { EXPECT_STREQ("2a", buffer); } -#ifdef __cpp_lib_bit_cast -TEST(compile_test, constexpr_formatted_size) { - FMT_CONSTEXPR20 size_t s1 = fmt::formatted_size(FMT_COMPILE("{0}"), 42); - EXPECT_EQ(2, s1); - FMT_CONSTEXPR20 size_t s2 = fmt::formatted_size(FMT_COMPILE("{0:<4.2f}"), 42.0); - EXPECT_EQ(5, s2); +TEST(compile_test, formatted_size) { + EXPECT_EQ(2, fmt::formatted_size(FMT_COMPILE("{0}"), 42)); + EXPECT_EQ(5, fmt::formatted_size(FMT_COMPILE("{0:<4.2f}"), 42.0)); } -#endif TEST(compile_test, text_and_arg) { EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42));