https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108024

            Bug ID: 108024
           Summary: std::format_string's constructor has the wrong
                    constraint
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

format#L3628:

  template<typename _CharT, typename... _Args>
    template<convertible_to<basic_string_view<_CharT>> _Tp>
      consteval
      basic_format_string<_CharT, _Args...>::
      basic_format_string(const _Tp& __s)
      : _M_str(__s)

>From [format.fmt.string]: "Constraints: const T& models
convertible_­to<basic_­string_­view<charT>>." We should use the requires-clause
to constrain const _Tp instead of _Tp. Testcase:

    #include <format>

    struct Str {
      consteval operator std::string_view() const { return ""; }
      operator std::string_view() = delete;
    };

    int main() {
      return std::format(Str{}).size();
    }

https://godbolt.org/z/xjq5K9YGo

Reply via email to