Defines | |
| #define | Printf(A,) vPrintf(A, (tag::Fmt,## __VA_ARGS__)) |
| #define | fPrintf(A, B,) vfPrintf(A,B, (tag::Fmt,## __VA_ARGS__)) |
| #define | sPrintf(A,) vsPrintf(A, (tag::Fmt,## __VA_ARGS__)) |
Functions | |
| template<class A, class B, class C, class D> | |
| void | tag::vfPrintf (std::basic_ostream< A, B > &o, const std::string fmt, const T_list< C, D > &l) |
| template<class C, class D> | |
| void | tag::vPrintf (const std::string fmt, const T_list< C, D > &l) |
| template<class C, class D> | |
| std::string | tag::vsPrintf (const std::string &fmt, const T_list< C, D > &l) |
Variables | |
| const T_ListEnd | tag::Fmt = TupleHead |
|
|
This is the equivalent to the C-style fprintf: it provides a variadic interface and prints to give ostream. See vfPrintf for details.
|
|
|
This is the equivalent to the C-style printf: it provides a variadic interface and prints to cout. See vfPrintf for details.
|
|
|
This is the equivalent to the C-style sprintf: it provides a variadic interface returns the string. See vfPrintf for details.
|
|
||||||||||||||||||||
|
This function provides the mose generic implementation, where a typelist and an ostream can be provided.
%[flags][width][.[precision]]<conversion>
FlagsFlags contains zero or more of:
WidthThe width is optional and must start with a non-zero digit. It seems to work even with overloaded operator<<
Precision
.[precision] This can mean one of two things:
ConversionThis is a single alphabetic character. This is the largets departure from the C style printf. This flag affects the "type" of the datum being formatted. Type safety still applies. Uppercase and lowercase conversions behave in exactly the same way, except uppercase ones cause uppercased output (where applicable). If a float looks like 1E6 intead of 1e6
Differences campared to C-stype printf
Unlike C, the C++ sytle printf can output values of any type for which operator<< is defined. Further, printf itself will not cause any undefined behaviour. Access beyond the end of the vargs list produces Note: length modifiers are not supported. See also other members of the Printf family:
Usage
vfPrintf(cout, "%s, %s\n", (Fmt, "Hello", "world")); |
|
||||||||||||||||
|
This prints to cout. See vfPrintf for details.
|
|
||||||||||||||||
|
This prints to a string. See vfPrintf for details.
|
|
|
List head for argument lists. This is a synonym for TupleHead Argument lists can be made by doing: (Fmt, arg1, arg2, ...) |
1.3.9.1