template<typename _CharT, typename... _Args>
struct basic_format_string
{
- template<convertible_to<basic_string_view<_CharT>> _Tp>
+ template<typename _Tp>
+ requires convertible_to<const _Tp&, basic_string_view<_CharT>>
consteval
basic_format_string(const _Tp& __s);
else
for (_CharT __c : __str)
*__out++ = __c;
- return std::move(__out);
+ return __out;
}
// Write STR to OUT with NFILL copies of FILL_CHAR specified by ALIGN.
__out = __format::__write(std::move(__out), __str);
__pad(__r, __out);
- return std::move(__out);
+ return __out;
}
// A lightweight optional<locale>.
/// @endcond
template<typename _CharT, typename... _Args>
- template<convertible_to<basic_string_view<_CharT>> _Tp>
+ template<typename _Tp>
+ requires convertible_to<const _Tp&, basic_string_view<_CharT>>
consteval
basic_format_string<_CharT, _Args...>::
basic_format_string(const _Tp& __s)
--- /dev/null
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <format>
+
+struct Str
+{
+ consteval operator std::string_view() const { return ""; }
+ operator std::string_view() = delete;
+};
+
+// PR libstdc++/108024
+static_assert( std::is_constructible_v<std::format_string<>, const Str&> );
+static_assert( std::is_convertible_v<const Str&, std::format_string<>> );
+
+constinit std::format_string<> s = Str();