15 #include <initializer_list> 16 #include <type_traits> 23 #ifdef FMT_DEPRECATED_BRACED_RANGES 31 template <
typename ParseContext>
41 template <
typename ParseContext>
49 template <
typename RangeT,
typename OutputIterator>
50 OutputIterator
copy(
const RangeT& range, OutputIterator out) {
51 for (
auto it = range.begin(), end = range.end(); it != end; ++it)
56 template <
typename OutputIterator>
57 OutputIterator
copy(
const char* str, OutputIterator out) {
58 while (*str) *out++ = *str++;
62 template <
typename OutputIterator>
63 OutputIterator
copy(
char ch, OutputIterator out) {
68 template <
typename OutputIterator>
69 OutputIterator
copy(
wchar_t ch, OutputIterator out) {
77 static auto check(U* p)
78 -> decltype((
void)p->find(
'a'), p->length(), (
void)p->data(), int());
79 template <
typename>
static void check(...);
86 template <
typename Char>
93 #if !FMT_MSC_VER || FMT_MSC_VER > 1800 95 # define FMT_DECLTYPE_RETURN(val) \ 96 ->decltype(val) { return val; } \ 98 true, "") // This makes it so that a semicolon is required after the 102 template <
typename T, std::
size_t N>
106 template <
typename T, std::
size_t N>
111 template <
typename T,
typename Enable =
void>
114 template <
typename T>
116 decltype(std::declval<T>().end())>>
120 template <
typename T>
122 template <
typename T>
127 template <
typename T>
130 decltype(begin(static_cast<T&&>(rng)))> {
131 return begin(static_cast<T&&>(rng));
133 template <
typename T>
135 decltype(end(static_cast<T&&>(rng)))> {
136 return end(static_cast<T&&>(rng));
139 template <
typename T,
typename Enable =
void>
141 template <
typename T,
typename Enable =
void>
144 template <
typename T>
147 std::declval<const remove_cvref_t<T>&>())),
148 decltype(detail::range_begin(
149 std::declval<const remove_cvref_t<T>&>()))>>
152 template <
typename T>
155 decltype(detail::range_begin(std::declval<T>())),
156 enable_if_t<std::is_copy_constructible<T>::value>>>
159 template <
typename T>
161 : std::integral_constant<bool, (has_const_begin_end<T>::value ||
162 has_mutable_begin_end<T>::value)> {};
165 template <
typename T>
173 static auto
view(const T& range) -> view_t {
return {&range}; }
176 template <
typename T>
185 static auto
view(const T& range) -> view_t {
return {range}; }
187 # undef FMT_DECLTYPE_RETURN 192 template <
typename U>
193 static auto check(U* p) -> decltype(std::tuple_size<U>::value,
int());
194 template <
typename>
static void check(...);
198 !std::is_void<decltype(check<T>(
nullptr))>
::value;
202 #if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900 203 template <
typename T, T... N>
208 template <
typename T, T... N>
struct integer_sequence {
214 template <
size_t... N>
using index_sequence = integer_sequence<
size_t, N...>;
216 template <
typename T,
size_t N, T... Ns>
218 template <
typename T, T... Ns>
225 template <
class Tuple,
class F,
size_t... Is>
229 const int _[] = {0, ((
void)
f(get<Is>(tup)), 0)...};
239 template <
class Tuple,
class F>
void for_each(Tuple&& tup, F&& f) {
241 for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(
f));
244 template <
typename Range>
255 typename Char,
typename OutputIt,
typename Arg,
259 out = write<Char>(out, v);
264 template <
typename Char,
typename OutputIt,
typename Arg,
274 typename Char,
typename OutputIt,
typename Arg,
276 !std::is_same<Arg, Char>::value)>
278 return write<Char>(out, v);
288 template <
typename TupleT,
typename Char>
292 template <
typename FormatContext>
struct format_each {
295 out = detail::write_range_entry<Char>(out, v);
300 typename std::add_lvalue_reference<
307 template <
typename ParseContext>
309 return formatting.
parse(ctx);
312 template <
typename FormatContext = format_context>
313 auto format(
const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) {
314 auto out = ctx.out();
325 template <
typename T,
typename Char>
struct is_range {
328 !std::is_convertible<T, std::basic_string<Char>>
::value &&
329 !std::is_constructible<detail::std_string_view<Char>, T>
::value;
332 template <
typename T,
typename Char>
338 #if !FMT_MSC_VER || FMT_MSC_VER >= 1927 339 && (has_formatter<detail::value_type<T>, format_context>::value ||
340 detail::has_fallback_formatter<detail::value_type<T>, Char>::value)
345 template <
typename ParseContext>
347 return formatting.
parse(ctx);
350 template <
typename FormatContext>
351 typename FormatContext::iterator
format(
const T& values, FormatContext& ctx) {
355 auto it =
view.begin();
356 auto end =
view.end();
357 for (; it != end; ++it) {
359 out = detail::write_range_entry<Char>(out, *it);
371 : tuple(t), sep{s} {}
374 template <
typename Char,
typename... T>
377 template <
typename Char,
typename... T>
379 template <
typename ParseContext>
384 template <
typename FormatContext>
386 typename FormatContext::iterator {
391 template <
typename FormatContext,
size_t... N>
394 typename FormatContext::iterator {
398 template <
typename FormatContext>
400 typename FormatContext::iterator {
406 template <
typename FormatContext,
typename Arg,
typename... Args>
408 const Arg&
arg,
const Args&...
args) ->
409 typename FormatContext::iterator {
411 auto out = base().format(
arg, ctx);
412 if (
sizeof...(Args) > 0) {
434 template <
typename... T>
440 template <
typename... T>
458 template <
typename T>
461 return join(std::begin(list), std::end(list), sep);
467 #endif // FMT_RANGES_H_ tuple_join_view(const std::tuple< T... > &t, basic_string_view< Char > s)
#define FMT_MODULE_EXPORT_END
#define FMT_ENABLE_IF(...)
typename std::remove_cv< remove_reference_t< T > >::type remove_cvref_t
basic_string_view< Char > sep
FMT_MODULE_EXPORT_BEGIN FMT_CONSTEXPR auto join(const std::tuple< T... > &tuple, string_view sep) -> tuple_join_view< char, T... >
span_CONFIG_SIZE_TYPE size_t
integer_sequence< size_t, N... > index_sequence
#define FMT_CONSTEXPR_DECL
Return true value if T has std::string interface, like std::string_view.
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
OutputIt write_delimiter(OutputIt out)
#define FMT_END_NAMESPACE
void for_each(Tuple &&tup, F &&f)
OutputIt write_range_entry(OutputIt out, const Arg v)
static FMT_CONSTEXPR size_t size()
integral_constant< bool, false > false_type
OutputIterator copy(const RangeT &range, OutputIterator out)
integral_constant< bool, true > true_type
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
tuple_size and tuple_element check.
auto range_end(T &&rng) -> enable_if_t<!has_member_fn_begin_end_t< T &&>::value, decltype(end(static_cast< T &&>(rng)))>
void for_each(index_sequence< Is... >, Tuple &&tup, F &&f) FMT_NOEXCEPT
basic_format_args< format_context > format_args
auto range_begin(T &&rng) -> enable_if_t<!has_member_fn_begin_end_t< T &&>::value, decltype(begin(static_cast< T &&>(rng)))>
static void check(LexState *ls, int c)
#define FMT_DECLTYPE_RETURN(val)
remove_cvref_t< decltype(*detail::range_begin(std::declval< Range >()))> value_type
typename std::enable_if< B, T >::type enable_if_t
const std::tuple< T... > & tuple
FMT_CONSTEXPR make_index_sequence< std::tuple_size< T >::value > get_indexes(T const &)
#define FMT_BEGIN_NAMESPACE
OutputIterator copy(wchar_t ch, OutputIterator out)
#define FMT_MODULE_EXPORT_BEGIN
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)