@@ -34,6 +34,11 @@ Distributed under the Boost Software License, Version 1.0.
34
34
#include < compare>
35
35
#endif
36
36
37
+ #if __cplusplus >= 202600L || _HAS_CXX26
38
+ #include < format>
39
+ #define LLFIO_PATH_VIEW_HAVE_FORMAT 1
40
+ #endif
41
+
37
42
#include " quickcpplib/algorithm/hash.hpp"
38
43
#include " quickcpplib/algorithm/string.hpp"
39
44
@@ -3199,6 +3204,55 @@ static_assert(std::is_trivially_copyable<path_view>::value, "path_view is not a
3199
3204
3200
3205
LLFIO_V2_NAMESPACE_END
3201
3206
3207
+ #if LLFIO_PATH_VIEW_HAVE_FORMAT
3208
+ template <class charT > struct std ::formatter<LLFIO_V2_NAMESPACE::path_view_component, charT>
3209
+ {
3210
+ std::formatter<std::filesystem::path, charT> fmt;
3211
+ constexpr void set_debug_format () { fmt.set_debug_format (); }
3212
+ constexpr typename std::basic_format_parse_context<charT>::iterator parse (std::basic_format_parse_context<charT> &ctx) { return fmt.parse (ctx); }
3213
+ template <class FormatContext > typename FormatContext::iterator format (const LLFIO_V2_NAMESPACE::path_view_component &pv, FormatContext &ctx) const
3214
+ {
3215
+ return LLFIO_V2_NAMESPACE::visit (
3216
+ [&](auto sv)
3217
+ {
3218
+ using type = typename decltype (sv)::value_type;
3219
+ if constexpr (std::is_same_v<type, std::byte>)
3220
+ {
3221
+ return fmt.format (std::filesystem::path (QUICKCPPLIB_NAMESPACE::algorithm::string::to_hex_string ((const char *) v.data (), v.size ())), ctx);
3222
+ }
3223
+ else
3224
+ {
3225
+ return fmt.format (std::filesystem::path (sv), ctx);
3226
+ }
3227
+ },
3228
+ pv);
3229
+ }
3230
+ };
3231
+ template <class charT > struct std ::formatter<LLFIO_V2_NAMESPACE::path_view, charT>
3232
+ {
3233
+ std::formatter<std::filesystem::path, charT> fmt;
3234
+ constexpr void set_debug_format () { fmt.set_debug_format (); }
3235
+ constexpr typename std::basic_format_parse_context<charT>::iterator parse (std::basic_format_parse_context<charT> &ctx) { return fmt.parse (ctx); }
3236
+ template <class FormatContext > typename FormatContext::iterator format (const LLFIO_V2_NAMESPACE::path_view &pv, FormatContext &ctx) const
3237
+ {
3238
+ return LLFIO_V2_NAMESPACE::visit (
3239
+ [&](auto sv)
3240
+ {
3241
+ using type = typename decltype (sv)::value_type;
3242
+ if constexpr (std::is_same_v<type, std::byte>)
3243
+ {
3244
+ return fmt.format (std::filesystem::path (QUICKCPPLIB_NAMESPACE::algorithm::string::to_hex_string ((const char *) v.data (), v.size ())), ctx);
3245
+ }
3246
+ else
3247
+ {
3248
+ return fmt.format (std::filesystem::path (sv), ctx);
3249
+ }
3250
+ },
3251
+ pv);
3252
+ }
3253
+ };
3254
+ #endif
3255
+
3202
3256
#if LLFIO_HEADERS_ONLY == 1 && !defined(DOXYGEN_SHOULD_SKIP_THIS)
3203
3257
#define LLFIO_INCLUDED_BY_HEADER 1
3204
3258
#include " detail/impl/path_view.ipp"
0 commit comments