|
|
|
|
@ -22,8 +22,6 @@ FMT_EXPORT class compiled_string {};
|
|
|
|
|
template <typename S>
|
|
|
|
|
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
|
|
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a string literal `s` into a format string that will be parsed at
|
|
|
|
|
* compile time and converted into efficient formatting code. Requires C++17
|
|
|
|
|
@ -41,18 +39,40 @@ namespace detail {
|
|
|
|
|
# define FMT_COMPILE(s) FMT_STRING(s)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a string literal into a format string that will be parsed at
|
|
|
|
|
* compile time and converted into efficient formatting code. Requires support
|
|
|
|
|
* for class types in constant template parameters (a C++20 feature).
|
|
|
|
|
*
|
|
|
|
|
* **Example**:
|
|
|
|
|
*
|
|
|
|
|
* // Converts 42 into std::string using the most efficient method and no
|
|
|
|
|
* // runtime format string processing.
|
|
|
|
|
* using namespace fmt::literals;
|
|
|
|
|
* std::string s = fmt::format("{}"_cf, 42);
|
|
|
|
|
*/
|
|
|
|
|
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
|
|
|
|
inline namespace literals {
|
|
|
|
|
template <detail::fixed_string Str> constexpr auto operator""_cf() {
|
|
|
|
|
return FMT_COMPILE(Str.data);
|
|
|
|
|
}
|
|
|
|
|
} // namespace literals
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
template <typename T, typename... Tail>
|
|
|
|
|
auto first(const T& value, const Tail&...) -> const T& {
|
|
|
|
|
constexpr auto first(const T& value, const Tail&...) -> const T& {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
|
|
|
|
template <typename... Args> struct type_list {};
|
|
|
|
|
template <typename... T> struct type_list {};
|
|
|
|
|
|
|
|
|
|
// Returns a reference to the argument at index N from [first, rest...].
|
|
|
|
|
template <int N, typename T, typename... Args>
|
|
|
|
|
constexpr const auto& get([[maybe_unused]] const T& first,
|
|
|
|
|
[[maybe_unused]] const Args&... rest) {
|
|
|
|
|
constexpr auto get([[maybe_unused]] const T& first,
|
|
|
|
|
[[maybe_unused]] const Args&... rest) -> const auto& {
|
|
|
|
|
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
|
|
|
|
|
if constexpr (N == 0)
|
|
|
|
|
return first;
|
|
|
|
|
@ -84,8 +104,8 @@ FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename Char, typename... Args>
|
|
|
|
|
constexpr int get_arg_index_by_name(basic_string_view<Char> name,
|
|
|
|
|
type_list<Args...>) {
|
|
|
|
|
constexpr auto get_arg_index_by_name(basic_string_view<Char> name,
|
|
|
|
|
type_list<Args...>) -> int {
|
|
|
|
|
return get_arg_index_by_name<Args...>(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -105,8 +125,8 @@ template <typename Char> struct text {
|
|
|
|
|
basic_string_view<Char> data;
|
|
|
|
|
using char_type = Char;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr OutputIt format(OutputIt out, const Args&...) const {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr auto format(OutputIt out, const T&...) const -> OutputIt {
|
|
|
|
|
return write<Char>(out, data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
@ -115,8 +135,8 @@ template <typename Char>
|
|
|
|
|
struct is_compiled_format<text<Char>> : std::true_type {};
|
|
|
|
|
|
|
|
|
|
template <typename Char>
|
|
|
|
|
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
|
|
|
|
|
size_t size) {
|
|
|
|
|
constexpr auto make_text(basic_string_view<Char> s, size_t pos, size_t size)
|
|
|
|
|
-> text<Char> {
|
|
|
|
|
return {{&s[pos], size}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -124,8 +144,8 @@ template <typename Char> struct code_unit {
|
|
|
|
|
Char value;
|
|
|
|
|
using char_type = Char;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr OutputIt format(OutputIt out, const Args&...) const {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr auto format(OutputIt out, const T&...) const -> OutputIt {
|
|
|
|
|
*out++ = value;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
@ -133,7 +153,7 @@ template <typename Char> struct code_unit {
|
|
|
|
|
|
|
|
|
|
// This ensures that the argument type is convertible to `const T&`.
|
|
|
|
|
template <typename T, int N, typename... Args>
|
|
|
|
|
constexpr const T& get_arg_checked(const Args&... args) {
|
|
|
|
|
constexpr auto get_arg_checked(const Args&... args) -> const T& {
|
|
|
|
|
const auto& arg = detail::get<N>(args...);
|
|
|
|
|
if constexpr (detail::is_named_arg<remove_cvref_t<decltype(arg)>>()) {
|
|
|
|
|
return arg.value;
|
|
|
|
|
@ -146,13 +166,13 @@ template <typename Char>
|
|
|
|
|
struct is_compiled_format<code_unit<Char>> : std::true_type {};
|
|
|
|
|
|
|
|
|
|
// A replacement field that refers to argument N.
|
|
|
|
|
template <typename Char, typename T, int N> struct field {
|
|
|
|
|
template <typename Char, typename V, int N> struct field {
|
|
|
|
|
using char_type = Char;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
|
|
|
|
const T& arg = get_arg_checked<T, N>(args...);
|
|
|
|
|
if constexpr (std::is_convertible<T, basic_string_view<Char>>::value) {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {
|
|
|
|
|
const V& arg = get_arg_checked<V, N>(args...);
|
|
|
|
|
if constexpr (std::is_convertible<V, basic_string_view<Char>>::value) {
|
|
|
|
|
auto s = basic_string_view<Char>(arg);
|
|
|
|
|
return copy<Char>(s.begin(), s.end(), out);
|
|
|
|
|
} else {
|
|
|
|
|
@ -170,10 +190,10 @@ template <typename Char> struct runtime_named_field {
|
|
|
|
|
basic_string_view<Char> name;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename T>
|
|
|
|
|
constexpr static bool try_format_argument(
|
|
|
|
|
constexpr static auto try_format_argument(
|
|
|
|
|
OutputIt& out,
|
|
|
|
|
// [[maybe_unused]] due to unused-but-set-parameter warning in GCC 7,8,9
|
|
|
|
|
[[maybe_unused]] basic_string_view<Char> arg_name, const T& arg) {
|
|
|
|
|
[[maybe_unused]] basic_string_view<Char> arg_name, const T& arg) -> bool {
|
|
|
|
|
if constexpr (is_named_arg<typename std::remove_cv<T>::type>::value) {
|
|
|
|
|
if (arg_name == arg.name) {
|
|
|
|
|
out = write<Char>(out, arg.value);
|
|
|
|
|
@ -183,8 +203,8 @@ template <typename Char> struct runtime_named_field {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {
|
|
|
|
|
bool found = (try_format_argument(out, name, args) || ...);
|
|
|
|
|
if (!found) {
|
|
|
|
|
FMT_THROW(format_error("argument with specified name is not found"));
|
|
|
|
|
@ -197,17 +217,17 @@ template <typename Char>
|
|
|
|
|
struct is_compiled_format<runtime_named_field<Char>> : std::true_type {};
|
|
|
|
|
|
|
|
|
|
// A replacement field that refers to argument N and has format specifiers.
|
|
|
|
|
template <typename Char, typename T, int N> struct spec_field {
|
|
|
|
|
template <typename Char, typename V, int N> struct spec_field {
|
|
|
|
|
using char_type = Char;
|
|
|
|
|
formatter<T, Char> fmt;
|
|
|
|
|
formatter<V, Char> fmt;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr FMT_INLINE OutputIt format(OutputIt out,
|
|
|
|
|
const Args&... args) const {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr FMT_INLINE auto format(OutputIt out, const T&... args) const
|
|
|
|
|
-> OutputIt {
|
|
|
|
|
const auto& vargs =
|
|
|
|
|
fmt::make_format_args<basic_format_context<OutputIt, Char>>(args...);
|
|
|
|
|
basic_format_context<OutputIt, Char> ctx(out, vargs);
|
|
|
|
|
return fmt.format(get_arg_checked<T, N>(args...), ctx);
|
|
|
|
|
return fmt.format(get_arg_checked<V, N>(args...), ctx);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -219,8 +239,8 @@ template <typename L, typename R> struct concat {
|
|
|
|
|
R rhs;
|
|
|
|
|
using char_type = typename L::char_type;
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename... Args>
|
|
|
|
|
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
|
|
|
|
template <typename OutputIt, typename... T>
|
|
|
|
|
constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {
|
|
|
|
|
out = lhs.format(out, args...);
|
|
|
|
|
return rhs.format(out, args...);
|
|
|
|
|
}
|
|
|
|
|
@ -230,14 +250,14 @@ template <typename L, typename R>
|
|
|
|
|
struct is_compiled_format<concat<L, R>> : std::true_type {};
|
|
|
|
|
|
|
|
|
|
template <typename L, typename R>
|
|
|
|
|
constexpr concat<L, R> make_concat(L lhs, R rhs) {
|
|
|
|
|
constexpr auto make_concat(L lhs, R rhs) -> concat<L, R> {
|
|
|
|
|
return {lhs, rhs};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct unknown_format {};
|
|
|
|
|
|
|
|
|
|
template <typename Char>
|
|
|
|
|
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
|
|
|
|
|
constexpr auto parse_text(basic_string_view<Char> str, size_t pos) -> size_t {
|
|
|
|
|
for (size_t size = str.size(); pos != size; ++pos) {
|
|
|
|
|
if (str[pos] == '{' || str[pos] == '}') break;
|
|
|
|
|
}
|
|
|
|
|
@ -270,8 +290,8 @@ template <typename T, typename Char> struct parse_specs_result {
|
|
|
|
|
enum { manual_indexing_id = -1 };
|
|
|
|
|
|
|
|
|
|
template <typename T, typename Char>
|
|
|
|
|
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
|
|
|
|
|
size_t pos, int next_arg_id) {
|
|
|
|
|
constexpr auto parse_specs(basic_string_view<Char> str, size_t pos,
|
|
|
|
|
int next_arg_id) -> parse_specs_result<T, Char> {
|
|
|
|
|
str.remove_prefix(pos);
|
|
|
|
|
auto ctx =
|
|
|
|
|
compile_parse_context<Char>(str, max_value<int>(), nullptr, next_arg_id);
|
|
|
|
|
@ -285,16 +305,16 @@ template <typename Char> struct arg_id_handler {
|
|
|
|
|
arg_id_kind kind;
|
|
|
|
|
arg_ref<Char> arg_id;
|
|
|
|
|
|
|
|
|
|
constexpr int on_auto() {
|
|
|
|
|
constexpr auto on_auto() -> int {
|
|
|
|
|
FMT_ASSERT(false, "handler cannot be used with automatic indexing");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
constexpr int on_index(int id) {
|
|
|
|
|
constexpr auto on_index(int id) -> int {
|
|
|
|
|
kind = arg_id_kind::index;
|
|
|
|
|
arg_id = arg_ref<Char>(id);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
constexpr int on_name(basic_string_view<Char> id) {
|
|
|
|
|
constexpr auto on_name(basic_string_view<Char> id) -> int {
|
|
|
|
|
kind = arg_id_kind::name;
|
|
|
|
|
arg_id = arg_ref<Char>(id);
|
|
|
|
|
return 0;
|
|
|
|
|
@ -433,27 +453,28 @@ FMT_BEGIN_EXPORT
|
|
|
|
|
|
|
|
|
|
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
|
|
|
|
|
|
|
|
|
template <typename CompiledFormat, typename... Args,
|
|
|
|
|
template <typename CompiledFormat, typename... T,
|
|
|
|
|
typename Char = typename CompiledFormat::char_type,
|
|
|
|
|
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
|
|
|
|
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
|
|
|
|
|
const Args&... args) {
|
|
|
|
|
FMT_INLINE FMT_CONSTEXPR_STRING auto format(const CompiledFormat& cf,
|
|
|
|
|
const T&... args)
|
|
|
|
|
-> std::basic_string<Char> {
|
|
|
|
|
auto s = std::basic_string<Char>();
|
|
|
|
|
cf.format(std::back_inserter(s), args...);
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
|
|
|
|
template <typename OutputIt, typename CompiledFormat, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
|
|
|
|
constexpr FMT_INLINE OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
|
|
|
|
const Args&... args) {
|
|
|
|
|
constexpr FMT_INLINE auto format_to(OutputIt out, const CompiledFormat& cf,
|
|
|
|
|
const T&... args) -> OutputIt {
|
|
|
|
|
return cf.format(out, args...);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename S, typename... Args,
|
|
|
|
|
template <typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
|
|
|
|
|
Args&&... args) {
|
|
|
|
|
FMT_INLINE FMT_CONSTEXPR_STRING auto format(const S&, T&&... args)
|
|
|
|
|
-> std::basic_string<typename S::char_type> {
|
|
|
|
|
if constexpr (std::is_same<typename S::char_type, char>::value) {
|
|
|
|
|
constexpr auto str = basic_string_view<typename S::char_type>(S());
|
|
|
|
|
if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') {
|
|
|
|
|
@ -466,72 +487,97 @@ FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
constexpr auto compiled = detail::compile<Args...>(S());
|
|
|
|
|
constexpr auto compiled = detail::compile<T...>(S());
|
|
|
|
|
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
|
|
|
|
|
detail::unknown_format>()) {
|
|
|
|
|
return fmt::format(
|
|
|
|
|
static_cast<basic_string_view<typename S::char_type>>(S()),
|
|
|
|
|
std::forward<Args>(args)...);
|
|
|
|
|
std::forward<T>(args)...);
|
|
|
|
|
} else {
|
|
|
|
|
return fmt::format(compiled, std::forward<Args>(args)...);
|
|
|
|
|
return fmt::format(compiled, std::forward<T>(args)...);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename S, typename... Args,
|
|
|
|
|
template <typename OutputIt, typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) {
|
|
|
|
|
constexpr auto compiled = detail::compile<Args...>(S());
|
|
|
|
|
FMT_CONSTEXPR auto format_to(OutputIt out, const S&, T&&... args) -> OutputIt {
|
|
|
|
|
constexpr auto compiled = detail::compile<T...>(S());
|
|
|
|
|
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
|
|
|
|
|
detail::unknown_format>()) {
|
|
|
|
|
return fmt::format_to(
|
|
|
|
|
out, static_cast<basic_string_view<typename S::char_type>>(S()),
|
|
|
|
|
std::forward<Args>(args)...);
|
|
|
|
|
std::forward<T>(args)...);
|
|
|
|
|
} else {
|
|
|
|
|
return fmt::format_to(out, compiled, std::forward<Args>(args)...);
|
|
|
|
|
return fmt::format_to(out, compiled, std::forward<T>(args)...);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
template <typename OutputIt, typename S, typename... Args,
|
|
|
|
|
template <typename OutputIt, typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)
|
|
|
|
|
auto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)
|
|
|
|
|
-> format_to_n_result<OutputIt> {
|
|
|
|
|
using traits = detail::fixed_buffer_traits;
|
|
|
|
|
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
|
|
|
|
|
fmt::format_to(std::back_inserter(buf), fmt, std::forward<Args>(args)...);
|
|
|
|
|
fmt::format_to(std::back_inserter(buf), fmt, std::forward<T>(args)...);
|
|
|
|
|
return {buf.out(), buf.count()};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename S, typename... Args,
|
|
|
|
|
template <typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
|
|
|
|
|
-> size_t {
|
|
|
|
|
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, T&&... args) -> size_t {
|
|
|
|
|
auto buf = detail::counting_buffer<>();
|
|
|
|
|
fmt::format_to(appender(buf), fmt, args...);
|
|
|
|
|
fmt::format_to(appender(buf), fmt, std::forward<T>(args)...);
|
|
|
|
|
return buf.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename S, typename... Args,
|
|
|
|
|
template <typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
void print(std::FILE* f, const S& fmt, const Args&... args) {
|
|
|
|
|
void print(std::FILE* f, const S& fmt, T&&... args) {
|
|
|
|
|
auto buf = memory_buffer();
|
|
|
|
|
fmt::format_to(appender(buf), fmt, args...);
|
|
|
|
|
fmt::format_to(appender(buf), fmt, std::forward<T>(args)...);
|
|
|
|
|
detail::print(f, {buf.data(), buf.size()});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename S, typename... Args,
|
|
|
|
|
template <typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
void print(const S& fmt, const Args&... args) {
|
|
|
|
|
print(stdout, fmt, args...);
|
|
|
|
|
void print(const S& fmt, T&&... args) {
|
|
|
|
|
print(stdout, fmt, std::forward<T>(args)...);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
|
|
|
|
inline namespace literals {
|
|
|
|
|
template <detail::fixed_string Str> constexpr auto operator""_cf() {
|
|
|
|
|
return FMT_COMPILE(Str.data);
|
|
|
|
|
}
|
|
|
|
|
} // namespace literals
|
|
|
|
|
#endif
|
|
|
|
|
template <size_t N> class static_format_result {
|
|
|
|
|
private:
|
|
|
|
|
char data[N];
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
template <typename S, typename... T,
|
|
|
|
|
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
|
|
|
|
explicit FMT_CONSTEXPR static_format_result(const S& fmt, T&&... args) {
|
|
|
|
|
*fmt::format_to(data, fmt, std::forward<T>(args)...) = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto str() const -> fmt::string_view { return {data, N - 1}; }
|
|
|
|
|
auto c_str() const -> const char* { return data; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Formats arguments according to the format string `fmt_str` and produces
|
|
|
|
|
* a string of the exact required size at compile time. Both the format string
|
|
|
|
|
* and the arguments must be compile-time expressions.
|
|
|
|
|
*
|
|
|
|
|
* The resulting string can be accessed as a C string via `c_str()` or as
|
|
|
|
|
* a `fmt::string_view` via `str()`.
|
|
|
|
|
*
|
|
|
|
|
* **Example**:
|
|
|
|
|
*
|
|
|
|
|
* // Produces the static string "42" at compile time.
|
|
|
|
|
* static constexpr auto result = FMT_STATIC_FORMAT("{}", 42);
|
|
|
|
|
* const char* s = result.c_str();
|
|
|
|
|
*/
|
|
|
|
|
#define FMT_STATIC_FORMAT(fmt_str, ...) \
|
|
|
|
|
fmt::static_format_result< \
|
|
|
|
|
fmt::formatted_size(FMT_COMPILE(fmt_str), __VA_ARGS__) + 1>( \
|
|
|
|
|
FMT_COMPILE(fmt_str), __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
FMT_END_EXPORT
|
|
|
|
|
FMT_END_NAMESPACE
|
|
|
|
|
|