| Member types | ||||||
| Member constants | ||||||
| Member functions | ||||||
| Path decomposition | ||||||
| Non-member functions | ||||||
| ||||||
| Helper classes | ||||||
| ||||||
Defined in header <filesystem> | ||
template<class CharT> struct formatter<std::filesystem::path, CharT>; | (since C++26) | |
The template specialization ofstd::formatter for thestd::filesystem::path class allows users to convert a pathname to its textual representation usingformatting functions. This specialization isdebug-enabled.
Contents |
The syntax of format specificationspath-format-spec is:
fill-and-align (optional)width (optional)?(optional)g(optional) | |||||||||
fill-and-align andwidth have the same meaning as instandard format specification.
The? option is used to format the pathname as anescaped string.
Theg option is used to specify that the pathname is ingeneric-format representation.
set_debug_format | enables to format the pathname as anescaped string (public member function) |
parse | parses the format specifier as specified bypath-format-spec (public member function) |
format | writes the formatted output as specified bypath-format-spec (public member function) |
constexprvoid set_debug_format(); | ||
Allows the current object to format pathname as anescaped string.
constexprauto parse(std::basic_format_parse_context<CharT>& ctx) ->std::basic_format_parse_context<CharT>::iterator; | ||
Parses the format specifiers as apath-format-spec and stores the parsed specifiers in the current object.
Returns an iterator past the end of thepath-format-spec.
template<class FormatContext> auto format(conststd::filesystem::path& p, FormatContext& ctx)const | ||
Lets bep.generic<std::filesystem::path::value_type>() if theg option is used, otherwisep.native(). Writess intoctx.out() as specified bypath-format-spec.
For character transcoding of the pathname:
U+FFFD REPLACEMENT CHARACTER ifReturns an iterator past the end of the output range.
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_format_path | 202403L | (C++26) | formatting support forstd::filesystem::path |
| This section is incomplete Reason: no example |
(C++20) | defines formatting rules for a given type (class template)[edit] |