15 #include <type_traits> 19 #ifndef FMT_RANGE_OUTPUT_LENGTH_LIMIT 20 # define FMT_RANGE_OUTPUT_LENGTH_LIMIT 256 26 template <
typename ParseContext>
32 template <
typename Char,
typename Enable =
void>
45 template <
typename Char,
typename Enable =
void>
57 template <
typename RangeT,
typename OutputIterator>
58 OutputIterator
copy(
const RangeT& range, OutputIterator out) {
59 for (
auto it = range.begin(), end = range.end(); it != end; ++it)
64 template <
typename OutputIterator>
65 OutputIterator
copy(
const char* str, OutputIterator out) {
66 while (*str) *out++ = *str++;
70 template <
typename OutputIterator>
71 OutputIterator
copy(
char ch, OutputIterator out) {
79 static auto check(U* p)
80 -> decltype((
void)p->find(
'a'), p->length(), (void)p->data(), int());
81 template <
typename>
static void check(...);
88 template <
typename Char>
93 template <
typename T,
typename _ =
void>
struct is_range_ : std::false_type {};
95 #if !FMT_MSC_VER || FMT_MSC_VER > 1800 100 decltype(std::declval<T>().end())>,
101 void>> : std::true_type {};
106 template <
typename U>
107 static auto check(U* p)
108 -> decltype(std::tuple_size<U>::value,
111 template <
typename>
static void check(...);
115 !std::is_void<decltype(check<T>(
nullptr))>
::value;
119 #if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900 120 template <
typename T, T... N>
123 template <std::
size_t N>
132 template <std::size_t... N>
135 template <
typename T, std::size_t N, T... Ns>
137 template <
typename T, T... Ns>
140 template <std::
size_t N>
144 template <
class Tuple,
class F,
size_t... Is>
148 const int _[] = {0, ((void)f(get<Is>(tup)), 0)...};
158 template <
class Tuple,
class F>
void for_each(Tuple&& tup, F&& f) {
160 for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
166 return add_space ?
" {}" :
"{}";
172 return add_space ?
" \"{}\"" :
"\"{}\"";
176 return add_space ?
" \"{}\"" :
"\"{}\"";
179 return add_space ? L
" \"{}\"" : L
"\"{}\"";
183 return add_space ?
" '{}'" :
"'{}'";
186 return add_space ? L
" '{}'" : L
"'{}'";
196 template <
typename TupleT,
typename Char>
200 template <
typename FormatContext>
struct format_each {
203 if (formatting.add_prepostfix_space) {
210 (formatting.add_delimiter_spaces && i > 0), v),
217 typename std::add_lvalue_reference<decltype(
224 template <
typename ParseContext>
226 return formatting.
parse(ctx);
229 template <
typename FormatContext = format_context>
230 auto format(
const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) {
231 auto out = ctx.out();
245 template <
typename T,
typename Char>
struct is_range {
249 !std::is_convertible<T, std::basic_string<Char>>::value &&
250 !std::is_constructible<internal::std_string_view<Char>, T>::value;
253 template <
typename RangeT,
typename Char>
258 template <
typename ParseContext>
260 return formatting.
parse(ctx);
263 template <
typename FormatContext>
264 typename FormatContext::iterator
format(
const RangeT& values,
265 FormatContext& ctx) {
268 for (
auto it = values.begin(), end = values.end(); it != end; ++it) {
278 out =
format_to(out,
" ... <other elements>");
292 : tuple{t}, sep{s} {}
295 template <
typename Char,
typename... T>
297 template <
typename ParseContext>
302 template <
typename FormatContext>
309 template <
typename FormatContext,
size_t... N>
316 template <
typename FormatContext>
324 template <
typename FormatContext,
typename Arg,
typename... Args>
327 const Arg&
arg,
const Args&... args) {
329 auto out = ctx.out();
330 out = base{}.format(arg, ctx);
331 if (
sizeof...(Args) > 0) {
351 template <
typename... T>
357 template <
typename... T>
365 #endif // FMT_RANGES_H_
#define FMT_BEGIN_NAMESPACE
static FMT_CONSTEXPR std::size_t size()
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
FMT_CONSTEXPR tuple_arg_join< char, T... > join(const std::tuple< T... > &tuple, string_view sep)
#define FMT_RANGE_OUTPUT_LENGTH_LIMIT
#define FMT_CONSTEXPR_DECL
FMT_CONSTEXPR const wchar_t * format_str_quoted(bool add_space, const wchar_t)
basic_string_view< Char > sep
OutputIt format_to(OutputIt out, const CompiledFormat &cf, const Args &... args)
#define FMT_END_NAMESPACE
tuple_size and tuple_element check.
void for_each(Tuple &&tup, F &&f)
typename std::enable_if< B, T >::type enable_if_t
FMT_CONSTEXPR make_index_sequence< std::tuple_size< T >::value > get_indexes(T const &)
FMT_CONSTEXPR const char * format_str_quoted(bool add_space, const Arg &)
OutputIterator copy(const RangeT &range, OutputIterator out)
#define FMT_ENABLE_IF(...)
typename std::conditional< B, T, F >::type conditional_t
void for_each(index_sequence< Is... >, Tuple &&tup, F &&f) FMT_NOEXCEPT
integer_sequence< std::size_t, N... > index_sequence
Return true value if T has std::string interface, like std::string_view.
tuple_arg_join(const std::tuple< T... > &t, basic_string_view< Char > s)
OutputIterator copy(char ch, OutputIterator out)
const std::tuple< T... > & tuple
internal::named_arg< T, Char > arg(const S &name, const T &arg)