From 108498bdd0bb3a15ecf0aed1e80cea98b249ffa3 Mon Sep 17 00:00:00 2001
From: Victor Zverovich
+2016-08-19
+
+Introduction
+This paper proposes a new text formatting functionality that can be used as a
+safe and extensible alternative to the
+Example:
+
+
+Variations of the printf format string syntax are arguably the most popular
+among the programming languages and C++ itself inherits
+Although it is possible to address these issues, this will break compatibility
+and can potentially be more confusing to users than introducing a different
+syntax.
+Text Formatting
+
+
+Design
+ Format String Syntax
+ Locale Support
+Wording
+References
+Introduction
+
+printf
family of functions.
+It is intended to complement the existing C++ I/O streams library and reuse
+some of its infrastructure such as overloaded insertion operators for
+user-defined types.
+
+
+
+std::string message = std::format("The answer is {}.", 42)
+Design
+
+Format String Syntax
+
+printf
+from C [1]. The advantage of the printf syntax is that many
+programmers are familiar with it. However, in its current form it has a number
+of issues:
+
+
+
+hh
, h
, l
,
+ j
, etc. are used only to convey type information.
+ They are redundant in type-safe formatting and would unnecessarily
+ complicate specification and parsing.'%'
in a custom format specifier, e.g. for
+ put_time
-like time formatting, poses difficulties.
'{'
and
+'}'
as replacement field delimiters instead of '%'
+and it is described in details in TODO:link. Here are some of the advantages:
+
+
++The syntax is expressive enough to enable translation, possibly automated, +of most printf format strings. TODO: table of correspondence between +printf and the new syntax +
+ +TODO
+ +TODO
+ ++The ideas proposed in this paper have been implemented in the open-source fmt +library. TODO: link +
+ +
+[1]
+The fprintf
function. ISO/IEC 9899:2011. 7.21.6.1.
+[2]
+
+fprintf, printf, snprintf, sprintf - print formatted output. The Open
+Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition.
+[3]
+
+6.1.3. Format String Syntax. Python 3.5.2 documentation.
+[4]
+
+String.Format Method. .NET Framework Class Library.
+[5]
+
+Module std::fmt
. The Rust Standard Library.
+