A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fmtlib/fmt/issues/4102 below:

non-constexpr formatted_size() breaks compile-time formatting · Issue #4102 · fmtlib/fmt · GitHub

Before f6b4a23b83 the function formatted_size() in compile.h was marked as FMT_CONSTEXPR20.

This allowed writing compile-time formatting using C++23's static constexpr members inside a constexpr function. E.g.:

template <fmt::detail::udl_compiled_string format, auto... values>
constexpr std::string_view constexpr_format() {
  static constexpr auto str = [] {
    constexpr auto result_length = fmt::formatted_size(format, values...);
    auto result = std::array<char, result_length>{};
    fmt::format_to(result.data(), format, values...);
    return result;
  }();
  return std::string_view(str.data(), str.size());
}

However, since the linked commit, this annotation was removed. Looking at the commit, I can't figure out why this is the case. Is there any chance of re-introducing the constexpr on all functions that allow it in compile.h?

PS: fmt::counting_buffer::count() is not marked constexpr either. When I wrote the snippet above, an fmt::counting_iterator was used instead in fmt::formatted_size() (but this iterator was removed in ba36a0481).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4