std::experi...::path::path(3)
π NAME π
okay so bestie, you're looking at std::experi...::path::path(3) from the C++ Standard Libary β yes, that's the manual name, typo and all, we're keeping it π. The page name is std::experimental::filesystem::path::path, and the NAME says it's literally std::experimental::filesystem::path::path β std::experimental::filesystem::path::path. Iconic redundancy, no notes.
β¨ Synopsis β¨
Constructs a new path object. Here are the overloads, exactly as they are, bestie:
path(); (1)
(filesystem TS)
path( const path& p ); (2)
(filesystem TS)
path( path&& p ); (3)
(filesystem TS)
template< class Source > (4)
(filesystem TS)
path( const Source& source );
template< class InputIt > (5)
(filesystem TS)
path( InputIt first, InputIt last );
template< class Source > (6)
(filesystem TS)
path( const Source& source, const std::locale& loc );
template< class InputIt > (7)
(filesystem TS)
path( InputIt first, InputIt last, const std::locale& loc );
Constructs a new path object. (Said it twice because it's important π .)
- 1) Constructs an empty path. Empty. Blank. A little path baby with nothing in it π.
- 2) Copy constructor. Constructs a copy of
p. - 3) Move constructor. Constructs a copy of
p,pis left in valid but unspecified state. (Not me leaving things in valid but unspecified state π.) - 4,5) Constructs the path from a character sequence provided by
source(4), which is a pointer or an input iterator to a null-terminated character/wide character sequence or anstd::basic_string, or represented as a pair of input iterators[first, last)(5). Any of the four character typeschar,char16_t,char32_t,wchar_tis allowed, and the method of conversion to the native character set depends on the character type used bysource.- 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
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).
- If the source character type is
- 6,7) Constructs the path from a character sequence provided by
source(6), which is a pointer or an input iterator to a null-terminated character sequence or anstd::string, or represented as a pair of input iterators[first, last)(7). The only character type allowed ischar. Useslocto perform the character encoding conversion. Ifvalue_typeiswchar_t, converts from to wide using thestd::codecvt<wchar_t, char, std::mbstate_t>facet ofloc. Otherwise, first converts to wide using thestd::codecvt<wchar_t, char, std::mbstate_t>facet and then converts to filesystem native character type usingstd::codecvt<wchar_t, value_type>facet ofloc.
π Parameters π
pβ a path to copy.sourceβ astd::basic_string, pointer to a null-terminated character string, or an input iterator with a character value type that points to a null-terminated character sequence (the character type must becharfor overload (6)).first,lastβ pair ofLegacyInputIteratorsthat specify a UTF-8 encoded character sequence.locβ locale that defines encoding conversion to use.
πΈ Type requirements πΈ
InputItmust meet the requirements ofLegacyInputIterator.- The value type of
InputItmust be one of the four character typeschar,wchar_t,char16_tandchar32_tto use the overload (5). - The value type of
InputItmust becharto use the overload (7).
π Exceptions π
- 1,2) (none)
- 3)
noexceptspecification:noexcept - 4-7) (none)
π¦ Notes π¦
For portable pathname generation from Unicode strings, see u8path.
π Example π
// Run this code
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p1 = "/usr/lib/sendmail.cf"; // portable format
fs::path p2 = "C:\\users\\abcdef\\AppData\\Local\\Temp\\"; // native format
fs::path p3 = L"D:/η«.txt"; // wide string
std::cout << "p1 = " << p1 << '\n'
<< "p2 = " << p2 << '\n'
<< "p3 = " << p3 << '\n';
}
Output:
p1 = "/usr/lib/sendmail.cf"
p2 = "C:\users\abcdef\AppData\Local\Temp\"
p3 = "D:/η«.txt"
π See also π
u8pathcreates a path from a UTF-8 encoded source (function).
π Categories π
- Noindexed pages
- unconditionally noexcept
π Hidden categories π
- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::experi...::path::path(3) β k bye bestie, drink water and don't leave your path in a valid but unspecified state ππ«Ά
π¦ 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