std::formatter(3)
β¨ NAME β¨
okay so this is std::formatter(3) from the C++ Standard Library, bestie. The name is literally std::formatter β std::formatter. Thatβs it. No cap. π
π¦ Synopsis π¦
Defined in header <filesystem>. And yes, this is the (since C++26) era, so mark your calendar. ποΈ
template< class CharT > (since C++26)
struct formatter<std::filesystem::path, CharT>;
The template specialization of std::formatter for the std::filesystem::path class lets users convert a pathname to its textual representation using formatting functions. This specialization is debug-enabled β iconic, honestly. β¨
π Member functions π
set_debug_formatβ enables to format the pathname as an escaped 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)
π std::formatter<std::filesystem::path>::set_debug_format
constexpr void set_debug_format();
Allows the current object to format pathname as an escaped string. Cute and useful, fr fr. π
πΈ std::formatter<std::filesystem::path>::parse
constexpr auto parse( std::basic_format_parse_context<CharT>& ctx )
-> std::basic_format_parse_context<CharT>::iterator;
Parses the format specifiers as a path-format-spec and stores the parsed specifiers in the current object.
Returns an iterator past the end of the path-format-spec. Slay. π
π¦ std::formatter<std::filesystem::path>::format
template< class FormatContext >
auto format( const std::filesystem::path& p, FormatContext& ctx ) const
-> FormatContext::iterator;
Let s be p.generic<std::filesystem::path::value_type>() if the g option is used, otherwise p.native(). Writes s into ctx.out() as specified by path-format-spec.
For character transcoding of the pathname:
- The pathname is transcoded from the native encoding for wide character strings to UTF-8 with maximal subparts of ill-formed subsequences substituted with
U+FFFD REPLACEMENT CHARACTERifstd::is_same_v<CharT, char>is true,std::is_same_v<typename path::value_type, wchar_t>is true, and- ordinary literal encoding is UTF-8.
- Otherwise, no transcoding is performed if
std::is_same_v<typename path::value_type, CharT>is true. - Otherwise, transcoding is implementation-defined.
Returns an iterator past the end of the output range. π«Ά
π Notes π
Feature-test macro __cpp_lib_format_path has value 202403L, std (C++26), and feature: formatting support for std::filesystem::path. periodt. π₯
π§ Example π§
This section is incomplete.
Reason: no example. π bestie we gotta add one later, no cap.
π See also π
formatterdefines formatting rules for a given type(C++20)(class template).
ποΈ Category ποΈ
Todo no example
Source/version: http://cppreference.com, dated 2024.06.10 β mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms