Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::formatter<std::filesystem::path>

      From cppreference.com
      <cpp‎ |filesystem‎ |path
       
       
      Filesystem library
      Classes
      Functions
      File types
       
      std::filesystem::path
      Member types
      Member constants
      Member functions
      Path decomposition
      Non-member functions
      (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
      Helper classes
      formatter<std::filesystem::path>
      (C++26)
       
      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

      [edit]Format specification

      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.

      [edit]Member functions

      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)

      std::formatter<std::filesystem::path>::set_debug_format

      constexprvoid set_debug_format();

      Allows the current object to format pathname as anescaped string.

      std::formatter<std::filesystem::path>::parse

      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.

      std::formatter<std::filesystem::path>::format

      template<class FormatContext>

      auto format(conststd::filesystem::path& p, FormatContext& ctx)const

         -> FormatContext::iterator;

      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:

      • The pathname is transcoded from the native encoding for wide character strings to UTF-8 with maximal subparts of ill-formed subsequences substituted withU+FFFD REPLACEMENT CHARACTER if
      • Otherwise, no transcoding is performed ifstd::is_same_v<typename path::value_type, CharT> istrue.
      • Otherwise, transcoding is implementation-defined.

      Returns an iterator past the end of the output range.

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_format_path202403L(C++26)formatting support forstd::filesystem::path

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      (C++20)
      defines formatting rules for a given type
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/path/formatter&oldid=170986"

      [8]ページ先頭

      ©2009-2025 Movatter.jp