-
Notifications
You must be signed in to change notification settings - Fork 12
ST::format
Michael Hansen edited this page Nov 22, 2019
·
5 revisions
#include <string_theory/format>
Name | Summary |
---|---|
ST::format | Format a UTF-8 ST::string from type-safe parameters |
ST::format_latin_1 | Format a Latin-1 ST::string from type-safe parameters |
Signature | |
---|---|
ST::string ST::format(const char *fmt_str, args_T ...args) template <typename... args_T> ST::string ST::format(const char *fmt_str, args_T &&...args) |
(1) |
ST::string ST::format(ST::utf_validation_t validation, const char *fmt_str, args_T ...args) template <typename... args_T> ST::string ST::format(ST::utf_validation_t validation, const char *fmt_str, args_T &&...args) |
(2) |
Creates a formatted ST::string object with the specified formatting and data.
- This function assumes UTF-8 and uses the default verification (specified by ST_DEFAULT_VALIDATION) to check the resulting string data.
- This function assumes UTF-8 and uses the
validation
parameter to control how the resulting string data is validated.
Changed in 3.0: The arguments in args
are now forwarded to reduce copying.
Signature |
---|
ST::string ST::format_latin_1(const char *fmt_str, args_T ...args) template <typename... args_T> ST::string ST::format_latin_1(const char *fmt_str, args_T &&...args) |
Creates a formatted ST::string object with the specified formatting and data. This function assumes Latin-1 data, which means that no validation is done on the input.
Changed in 3.0: The arguments in args
are now forwarded to reduce copying.
using namespace ST::literals;
Signature |
---|
opaque-type operator"" _stfmt(const char *fmt_str, size_t size) |
User-defined literal operator to invoke ST::format
on a literal string.
The returned object is opaque, but provides an operator()
overload to
conveniently invoke ST::format
.
auto str = "The answer is {}"_stfmt(42);
// Equivalent to:
auto str = ST::format("The answer is {}", 42);
Since: string_theory 3.0.