17#if FMT_HAS_INCLUDE(<version>)
21#if FMT_CPLUSPLUS >= 201703L
22#if FMT_HAS_INCLUDE(<filesystem>)
25#if FMT_HAS_INCLUDE(<variant>)
30#ifdef __cpp_lib_filesystem
36 template <
typename Char>
38 const std::filesystem::path&
p)
40 write_escaped_string<Char>(std::back_inserter(quoted),
p.string<Char>());
45 const std::filesystem::path&
p)
47 auto s =
p.u8string();
48 write_escaped_string<char>(
49 std::back_inserter(quoted),
50 string_view(
reinterpret_cast<const char*
>(
s.c_str()),
s.size()));
54 inline void write_escaped_path<std::filesystem::path::value_type>(
56 const std::filesystem::path&
p)
58 write_escaped_string<std::filesystem::path::value_type>(
59 std::back_inserter(quoted),
p.native());
64template <
typename Char>
68 template <
typename FormatContext>
69 auto format(
const std::filesystem::path&
p, FormatContext& ctx)
const ->
70 typename FormatContext::iterator
73 detail::write_escaped_path(quoted,
p);
82template <
typename Char>
88#ifdef __cpp_lib_variant
90template <
typename Char>
93 template <
typename ParseContext>
94 FMT_CONSTEXPR auto parse(ParseContext& ctx) ->
decltype(ctx.begin())
99 template <
typename FormatContext>
100 auto format(
const std::monostate&, FormatContext& ctx)
const
101 ->
decltype(ctx.out())
103 auto out = ctx.out();
104 out = detail::write<Char>(
out,
"monostate");
112 template <
typename T>
113 using variant_index_sequence =
114 std::make_index_sequence<std::variant_size<T>::value>;
117 template <
typename T,
typename U =
void>
118 struct is_variant_like_ : std::false_type
121 template <
typename T>
122 struct is_variant_like_<T,
std::
void_t<decltype(std::variant_size<T>::value)>>
128 template <
typename T,
typename C>
129 class is_variant_formattable_
131 template <std::size_t... I>
132 static std::conjunction<
134 check(std::index_sequence<I...>);
137 static constexpr const bool value =
138 decltype(check(variant_index_sequence<T>{}))
::value;
141 template <
typename Char,
typename OutputIt,
typename T>
142 auto write_variant_alternative(OutputIt
out,
const T& v) -> OutputIt
145 return write_escaped_string<Char>(
out, detail::to_string_view(v));
146 else if constexpr (std::is_same_v<T, Char>)
149 return write<Char>(
out, v);
155struct is_variant_like
157 static constexpr const bool value = detail::is_variant_like_<T>::value;
160template <
typename T,
typename C>
161struct is_variant_formattable
163 static constexpr const bool value =
164 detail::is_variant_formattable_<T, C>::value;
167template <
typename Variant,
typename Char>
172 is_variant_like<Variant>,
173 is_variant_formattable<Variant, Char>>>>
175 template <
typename ParseContext>
176 FMT_CONSTEXPR auto parse(ParseContext& ctx) ->
decltype(ctx.begin())
181 template <
typename FormatContext>
182 auto format(
const Variant&
value, FormatContext& ctx)
const
183 ->
decltype(ctx.out())
185 auto out = ctx.out();
187 out = detail::write<Char>(
out,
"variant(");
190 out = detail::write_variant_alternative<Char>(
out, v);
typename std::enable_if< B, T >::type enable_if_t
Definition core.h:302
FMT_NODISCARD FMT_INLINE auto format(format_string< T... > fmt, T &&... args) -> std::string
Definition core.h:4090
basic_string_view< char > string_view
Definition core.h:604
#define FMT_CONSTEXPR
Definition core.h:106
bool_constant< !std::is_base_of< detail::unformattable, decltype(detail::arg_mapper< buffer_context< Char > >().map(std::declval< T >()))>::value &&!detail::has_fallback_formatter< T, Char >::value > is_formattable
Definition core.h:2427
#define FMT_BEGIN_NAMESPACE
Definition core.h:214
void void_t
Definition core.h:2201
#define FMT_END_NAMESPACE
Definition core.h:219
#define out
Definition encodings.cpp:5
s
Definition tag_strings.h:47
p
Definition tag_strings.h:29