// <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2918r2.html>,
// uses a new symbol std::runtime_format, that
// - does not exist in g++ 13.3,
-// - exists in g++ 14 or newer and clang++ 19 or newer, but requires the
+// - exists in g++ 14..15 and clang++ 19..22, but requires the
// option -std=gnu++26.
+// This replacement API was then incompatibly modified in
+// <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3953r3.html>,
+// renaming std::runtime_format to std::dynamic_format. It is supported in
+// g++ 16 or newer and clang++ 23 or newer.
#include <format>
#include <iostream>
using namespace std;
+#if __cpp_lib_format > 202106L && __cpp_lib_format < 202603L
+# define dynamic_format runtime_format
+#endif
// Get setlocale() declaration.
#include <locale.h>
cout << vformat (_("This program is running as process number {:d}."),
make_format_args (getpid ()))
#else
- cout << format (runtime_format (_("This program is running as process number {:d}.")),
+ cout << format (dynamic_format (_("This program is running as process number {:d}.")),
getpid ())
#endif
<< endl;
using std::vformat;
using std::make_format_args;
#else
+# if __cpp_lib_format < 202603L
+# define dynamic_format runtime_format
+# endif
using std::format;
-using std::runtime_format;
+using std::dynamic_format;
#endif
EOF
if ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c test.cc 2>/dev/null; then
#include <format>
#include <iostream>
using namespace std;
+#if __cpp_lib_format > 202106L && __cpp_lib_format < 202603L
+# define dynamic_format runtime_format
+#endif
#include <libintl.h>
#include <locale.h>
cout << vformat (ngettext ("a piece of cake", "{} pieces of cake", n),
make_format_args (n))
#else
- cout << format (runtime_format (ngettext ("a piece of cake", "{} pieces of cake", n)),
+ cout << format (dynamic_format (ngettext ("a piece of cake", "{} pieces of cake", n)),
n)
#endif
<< endl;
#if __cpp_lib_format <= 202106L
cout << vformat (_("{} is replaced by {}."), make_format_args ("FF", "EUR"))
#else
- cout << format (runtime_format (_("{} is replaced by {}.")), "FF", "EUR")
+ cout << format (dynamic_format (_("{} is replaced by {}.")), "FF", "EUR")
#endif
<< endl;
}
cat <<\EOF > test.cc
#include <format>
using std::format;
-using std::runtime_format;
+using std::dynamic_format;
EOF
if ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c test.cc 2>/dev/null; then
CXX26=
cout << _("'Your command, please?', asked the waiter.") << endl;
- cout << format (runtime_format (ngettext ("a piece of cake", "{} pieces of cake", n)),
+ cout << format (dynamic_format (ngettext ("a piece of cake", "{} pieces of cake", n)),
n)
<< endl;
- cout << format (runtime_format (_("{} is replaced by {}.")), "FF", "EUR")
+ cout << format (dynamic_format (_("{} is replaced by {}.")), "FF", "EUR")
<< endl;
}
EOF