Namespaces
Variants
Actions

std::filesystem::path::path

From cppreference.com
< cpp‎ | filesystem‎ | path
 
 
 
 
path() noexcept;
(1) (since C++17)
path( const path& p );
(2) (since C++17)
path( path&& p ) noexcept;
(3) (since C++17)
path( string_type&& source, format fmt = auto_format );
(4) (since C++17)
template< class Source >
path( const Source& source, format fmt = auto_format );
(5) (since C++17)
template< class InputIt >
path( InputIt first, InputIt last, format fmt = auto_format );
(6) (since C++17)
template< class Source >
path( const Source& source, const std::locale& loc, format fmt = auto_format );
(7) (since C++17)
template< class InputIt >
path( InputIt first, InputIt last, const std::locale& loc, format fmt = auto_format );
(8) (since C++17)

Constructs a new path object.

1) Constructs an empty path.
2) Copy constructor. Constructs a path whose pathname, in both native and generic formats, is the same as that of p.
3) Move constructor. Constructs a path whose pathname, in both native and generic formats, is the same as that of p, p is left in valid but unspecified state.
4-6) Constructs the path from a character sequence (format interpreted as specified by fmt) provided by source (4,5), which is a pointer or an input iterator to a null-terminated character/wide character sequence, an std::basic_string or an std::basic_string_view, or represented as a pair of input iterators [first, last) (6). Any of the character types char, char8_t, (since C++20)char16_t, char32_t, wchar_t is allowed, and the method of conversion to the native character set depends on the character type used by source.
  • If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (so no conversion takes place on POSIX systems).
  • If the source character type is char8_t, conversion from UTF-8 to native filesystem encoding is used.
(since C++20)
  • If the source character type is char16_t, conversion from UTF-16 to native filesystem encoding is used.
  • If the source character type is char32_t, conversion from UTF-32 to native filesystem encoding is used.
  • If the source character type is wchar_t, the input is assumed to be the native wide encoding (so no conversion takes places on Windows).
7,8) Constructs the path from a character sequence (format interpreted as specified by fmt) provided by source (7), which is a pointer or an input iterator to a null-terminated character sequence, an std::string, an std::string_view, or represented as a pair of input iterators [first, last) (8). The only character type allowed is char. Uses loc to perform the character encoding conversion. If value_type is wchar_t, converts from to wide using the std::codecvt<wchar_t, char, std::mbstate_t> facet of loc. Otherwise, first converts to wide using the std::codecvt<wchar_t, char, std::mbstate_t> facet and then converts to filesystem native character type using std::codecvt<wchar_t,value_type> facet of loc.

(5) and (7) participate in overload resolution only if Source and path are not the same type, and either: