25#include "basic_string.hpp"
26#include "globalization/globalized_arg.hpp"
27#include "zstring_view.hpp"
35#if __has_include(<version> )
39#ifdef CPP_ESSENCE_USE_STD_FORMAT
44#include <fmt/format.h>
49 using ES_FMT_NS::format;
50 using ES_FMT_NS::format_string;
51 using ES_FMT_NS::format_to;
52 using ES_FMT_NS::make_format_args;
53 using ES_FMT_NS::make_wformat_args;
54 using ES_FMT_NS::vformat;
55 using ES_FMT_NS::wformat_string;
66 template <
typename... Args>
68 const std::locale& locale, format_string<globalization::globalized_arg_t<Args>...> fmt, Args&&... args) {
69 return format(locale, fmt, globalization::make_globalized_arg(locale, std::forward<Args>(args))...);
80 template <std_basic_string S = std::string,
typename... Args>
81 S format_as(format_string<Args...> fmt, Args&&... args)
82 requires requires(S str) { format_to(std::back_inserter(str), fmt, std::forward<Args>(args)...); }
86 format_to(std::back_inserter(result), fmt, std::forward<Args>(args)...);
87 result.shrink_to_fit();
101 template <std_basic_string S = std::string,
typename... Args>
102 S format_as(
const std::locale& locale, format_string<Args...> fmt, Args&&... args)
103 requires requires(S str) { format_to(std::back_inserter(str), fmt, std::forward<Args>(args)...); }
107 format_to(std::back_inserter(result), locale, fmt, std::forward<Args>(args)...);
108 result.shrink_to_fit();
124 template <std_basic_string S = std::string,
typename... Args>
125 S gformat_as(
const std::locale& locale, format_string<globalization::globalized_arg_t<Args>...> fmt, Args&&... args)
126 requires requires(S str) {
128 std::back_inserter(str), fmt, globalization::make_globalized_arg(locale, std::forward<Args>(args))...);
131 return format_as<S>(locale, fmt, globalization::make_globalized_arg(locale, std::forward<Args>(args))...);
135template <
typename CharT,
typename Traits>
136struct ES_FMT_NS::formatter<essence::basic_zstring_view<CharT, Traits>, CharT>
137 : formatter<std::basic_string_view<CharT, Traits>, CharT> {
138 template <
typename FormatContext>
140 return formatter<std::basic_string_view<CharT, Traits>, CharT>::format(
141 std::basic_string_view<CharT, Traits>{str}, ctx);
Definition zstring_view.hpp:34