| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Path decomposition | ||||
| Non-member functions | ||||
path(); | (1) | (filesystem TS) |
path(const path& p); | (2) | (filesystem TS) |
path( path&& p); | (3) | (filesystem TS) |
template<class Source> path(const Source& source); | (4) | (filesystem TS) |
template<class InputIt> path( InputIt first, InputIt last); | (5) | (filesystem TS) |
template<class Source> path(const Source& source,conststd::locale& loc); | (6) | (filesystem TS) |
template<class InputIt> path( InputIt first, InputIt last,conststd::locale& loc); | (7) | (filesystem TS) |
Constructs a newpath object.
value_type iswchar_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.Contents |
| 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 bechar for overload(6) |
| first, last | - | pair ofLegacyInputIterators that specify a UTF-8 encoded character sequence |
| loc | - | locale that defines encoding conversion to use |
| Type requirements | ||
-InputIt must meet the requirements ofLegacyInputIterator. | ||
-The value type ofInputIt must be one of the four character typeschar,wchar_t,char16_t andchar32_t to use the overload(5). | ||
-The value type ofInputIt must bechar to use the overload(7). | ||
For portable pathname generation from Unicode strings, seeu8path.
#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"
creates apath from a UTF-8 encoded source(function)[edit] |