libstdc++: Disable std::formatter::set_debug_format [PR112832]
All set_debug_format member functions should be guarded by the __cpp_lib_formatting_ranges macro (which is not defined yet). libstdc++-v3/ChangeLog: PR libstdc++/112832 * include/std/format (formatter::set_debug_format): Ensure this member is defined conditionally for all specializations. * testsuite/std/format/formatter/112832.cc: New test.
This commit is contained in:
parent
9fff752695
commit
3cd73543a1
2 changed files with 37 additions and 0 deletions
|
@ -1815,9 +1815,11 @@ namespace __format
|
|||
return _M_f.format(__u, __fc);
|
||||
}
|
||||
|
||||
#if __cpp_lib_format_ranges
|
||||
constexpr void
|
||||
set_debug_format() noexcept
|
||||
{ _M_f._M_spec._M_type = __format::_Pres_esc; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
__format::__formatter_int<wchar_t> _M_f;
|
||||
|
@ -1843,7 +1845,9 @@ namespace __format
|
|||
format(_CharT* __u, basic_format_context<_Out, _CharT>& __fc) const
|
||||
{ return _M_f.format(__u, __fc); }
|
||||
|
||||
#if __cpp_lib_format_ranges
|
||||
constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
__format::__formatter_str<_CharT> _M_f;
|
||||
|
@ -1866,7 +1870,9 @@ namespace __format
|
|||
basic_format_context<_Out, _CharT>& __fc) const
|
||||
{ return _M_f.format(__u, __fc); }
|
||||
|
||||
#if __cpp_lib_format_ranges
|
||||
constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
__format::__formatter_str<_CharT> _M_f;
|
||||
|
@ -1888,7 +1894,9 @@ namespace __format
|
|||
basic_format_context<_Out, _CharT>& __fc) const
|
||||
{ return _M_f.format({__u, _Nm}, __fc); }
|
||||
|
||||
#if __cpp_lib_format_ranges
|
||||
constexpr void set_debug_format() noexcept { _M_f.set_debug_format(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
__format::__formatter_str<_CharT> _M_f;
|
||||
|
|
29
libstdc++-v3/testsuite/std/format/formatter/112832.cc
Normal file
29
libstdc++-v3/testsuite/std/format/formatter/112832.cc
Normal file
|
@ -0,0 +1,29 @@
|
|||
// { dg-do compile { target c++20 } }
|
||||
|
||||
#include <format>
|
||||
|
||||
template<typename T,
|
||||
typename C = std::remove_cvref_t<decltype(std::declval<T&>()[0])>>
|
||||
constexpr bool
|
||||
test_pr112832()
|
||||
{
|
||||
std::formatter<T, C> f;
|
||||
if constexpr (requires{ f.set_debug_format(); })
|
||||
f.set_debug_format();
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert(test_pr112832<std::string_view>());
|
||||
static_assert(test_pr112832<char*>());
|
||||
static_assert(test_pr112832<const char*>());
|
||||
static_assert(test_pr112832<char[1]>());
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
static_assert(test_pr112832<std::wstring_view>());
|
||||
static_assert(test_pr112832<wchar_t*>());
|
||||
static_assert(test_pr112832<const wchar_t*>());
|
||||
static_assert(test_pr112832<wchar_t[1]>());
|
||||
static_assert(test_pr112832<char, wchar_t>());
|
||||
#endif
|
||||
}
|
Loading…
Add table
Reference in a new issue