static constexpr const _CharT* _S_empty_spec = _S_chars + 18;
[[__gnu__::__always_inline__]]
- static _Runtime_format_string<_CharT>
+ static _Dynamic_format_string<_CharT>
_S_empty_fs()
- { return _Runtime_format_string<_CharT>(_S_empty_spec); }
+ { return _Dynamic_format_string<_CharT>(_S_empty_spec); }
static constexpr const _CharT* _S_weekdays[]
{
if (__conv != 'y' && __ci >= 100) [[unlikely]]
{
- using _FmtStr = _Runtime_format_string<_CharT>;
+ using _FmtStr = _Dynamic_format_string<_CharT>;
__string_view __fs = _S_minus_empty_spec + !__is_neg;
__out = std::format_to(std::move(__out), _FmtStr(__fs),
__conv == 'C' ? __ci : __yi);
if (__mi >= 100 || __di >= 100) [[unlikely]]
{
- using _FmtStr = _Runtime_format_string<_CharT>;
+ using _FmtStr = _Dynamic_format_string<_CharT>;
__string_view __fs = _GLIBCXX_WIDEN("{:02d}/{:02d}/{:02d}");
__out = std::format_to(std::move(__out), _FmtStr(__fs),
__mi, __di, __yi);
if (__yi >= 10000 || __mi >= 100 || __di >= 100) [[unlikely]]
{
- using _FmtStr = _Runtime_format_string<_CharT>;
+ using _FmtStr = _Dynamic_format_string<_CharT>;
__string_view __fs
= _GLIBCXX_WIDEN("-{:04d}-{:02d}-{:02d}") + !__is_neg;
__out = std::format_to(std::move(__out), _FmtStr(__fs),
else if (__prec > __max_prec)
__prec = __max_prec;
- using _FmtStr = _Runtime_format_string<_CharT>;
+ using _FmtStr = _Dynamic_format_string<_CharT>;
return std::format_to(__out, _FmtStr(_GLIBCXX_WIDEN("{0:0{1}}")),
__subs, __prec);
}
_Out
_M_format_to(_Out __out, const chrono::sys_info& __si) const
{
- using _FmtStr = _Runtime_format_string<_CharT>;
+ using _FmtStr = _Dynamic_format_string<_CharT>;
// n.b. only decimal separator is locale dependent for specifiers
// used below, as sys_info uses seconds and minutes duration, the
// output is locale-independent.
// 202305 P2757R3 Type checking format args
// 202306 P2637R3 Member visit
// 202311 P2918R2 Runtime format strings II
+ // 202603 P3953R3 Rename std::runtime_format
values = {
- v = 202311;
+ v = 202603;
cxxmin = 26;
hosted = yes;
};
#if !defined(__cpp_lib_format)
# if (__cplusplus > 202302L) && _GLIBCXX_HOSTED
-# define __glibcxx_format 202311L
+# define __glibcxx_format 202603L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_format)
-# define __cpp_lib_format 202311L
+# define __cpp_lib_format 202603L
# endif
# elif (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
# define __glibcxx_format 202304L
using __format_context = basic_format_context<_Sink_iter<_CharT>, _CharT>;
template<typename _CharT>
- struct _Runtime_format_string
+ struct _Dynamic_format_string
{
[[__gnu__::__always_inline__]]
- _Runtime_format_string(basic_string_view<_CharT> __s) noexcept
+ _Dynamic_format_string(basic_string_view<_CharT> __s) noexcept
: _M_str(__s) { }
- _Runtime_format_string(const _Runtime_format_string&) = delete;
- void operator=(const _Runtime_format_string&) = delete;
+ _Dynamic_format_string(const _Dynamic_format_string&) = delete;
+ void operator=(const _Dynamic_format_string&) = delete;
private:
basic_string_view<_CharT> _M_str;
basic_format_string(const _Tp& __s);
[[__gnu__::__always_inline__]]
- basic_format_string(__format::_Runtime_format_string<_CharT> __s) noexcept
+ basic_format_string(__format::_Dynamic_format_string<_CharT> __s) noexcept
: _M_str(__s._M_str)
{ }
#if __cpp_lib_format >= 202311L // >= C++26
[[__gnu__::__always_inline__]]
- inline __format::_Runtime_format_string<char>
- runtime_format(string_view __fmt) noexcept
+ inline __format::_Dynamic_format_string<char>
+ dynamic_format(string_view __fmt) noexcept
{ return __fmt; }
#ifdef _GLIBCXX_USE_WCHAR_T
[[__gnu__::__always_inline__]]
- inline __format::_Runtime_format_string<wchar_t>
- runtime_format(wstring_view __fmt) noexcept
+ inline __format::_Dynamic_format_string<wchar_t>
+ dynamic_format(wstring_view __fmt) noexcept
{ return __fmt; }
#endif
#endif // C++26
(enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>> && ...);
// The standard wants us to call
- // print(stream, runtime_format(string(fmt.get()) + '\n'), args...)
+ // print(stream, dynamic_format(string(fmt.get()) + '\n'), args...)
// here, but we can avoid that string concatenation in most cases,
// and we know what that would call, so we can call that directly.
test_char()
{
std::string fmt = "{}";
- auto s = std::format(std::runtime_format(fmt), 123);
+ auto s = std::format(std::dynamic_format(fmt), 123);
VERIFY( s == "123" );
}
test_wchar()
{
std::wstring fmt = L"{:#o}";
- auto s = std::format(std::runtime_format(fmt), 456);
+ auto s = std::format(std::dynamic_format(fmt), 456);
VERIFY( s == L"0710" );
}
void
test_internal_api()
{
- // Using _Runtime_format_string directly works even in C++20 mode.
+ // Using _Dynamic_format_string directly works even in C++20 mode.
// This can be used internally by libstdc++.
std::string fmt = "{:#x}";
- auto s = std::format(std::__format::_Runtime_format_string<char>(fmt), 789);
+ auto s = std::format(std::__format::_Dynamic_format_string<char>(fmt), 789);
VERIFY( s == "0x315" );
}
-static_assert( noexcept(std::format_string<>(std::runtime_format(""))) );
-static_assert( noexcept(std::wformat_string<>(std::runtime_format(L""))) );
-static_assert( noexcept(std::format_string<int>(std::runtime_format(""))) );
-static_assert( noexcept(std::wformat_string<char>(std::runtime_format(L""))) );
-// A format string can be constructed from the result of std::runtime_format
+static_assert( noexcept(std::format_string<>(std::dynamic_format(""))) );
+static_assert( noexcept(std::wformat_string<>(std::dynamic_format(L""))) );
+static_assert( noexcept(std::format_string<int>(std::dynamic_format(""))) );
+static_assert( noexcept(std::wformat_string<char>(std::dynamic_format(L""))) );
+// A format string can be constructed from the result of std::dynamic_format
// using copy elision, but cannot be constructed from an xvalue.
static_assert( !std::is_constructible_v<std::format_string<>,
- decltype(std::runtime_format(""))&&> );
+ decltype(std::dynamic_format(""))&&> );
static_assert( !std::is_constructible_v<std::wformat_string<>,
- decltype(std::runtime_format(L""))&&> );
+ decltype(std::dynamic_format(L""))&&> );
int main()
{