@@ -111,6 +111,18 @@ void write_escaped_path(basic_memory_buffer<Char>& quoted,
111111 }
112112}
113113
114+ #if defined(__cpp_lib_expected) || FMT_CPP_LIB_VARIANT
115+
116+ template <typename Char, typename OutputIt, typename T>
117+ auto write_escaped_alternative (OutputIt out, const T& v) -> OutputIt {
118+ if constexpr (has_to_string_view<T>::value)
119+ return write_escaped_string<Char>(out, detail::to_string_view (v));
120+ if constexpr (std::is_same_v<T, Char>) return write_escaped_char (out, v);
121+ return write<Char>(out, v);
122+ }
123+
124+ #endif
125+
114126} // namespace detail
115127
116128template <typename Char> struct formatter <std::filesystem::path, Char> {
@@ -254,24 +266,6 @@ struct formatter<std::optional<T>, Char,
254266FMT_END_NAMESPACE
255267#endif // __cpp_lib_optional
256268
257- #if defined(__cpp_lib_expected) || FMT_CPP_LIB_VARIANT
258-
259- FMT_BEGIN_NAMESPACE
260- namespace detail {
261-
262- template <typename Char, typename OutputIt, typename T>
263- auto write_escaped_alternative (OutputIt out, const T& v) -> OutputIt {
264- if constexpr (has_to_string_view<T>::value)
265- return write_escaped_string<Char>(out, detail::to_string_view (v));
266- if constexpr (std::is_same_v<T, Char>) return write_escaped_char (out, v);
267- return write<Char>(out, v);
268- }
269-
270- } // namespace detail
271-
272- FMT_END_NAMESPACE
273- #endif
274-
275269#ifdef __cpp_lib_expected
276270FMT_BEGIN_NAMESPACE
277271
@@ -725,4 +719,5 @@ struct formatter<std::reference_wrapper<T>, Char,
725719};
726720
727721FMT_END_NAMESPACE
722+
728723#endif // FMT_STD_H_
0 commit comments