| Member types | ||||||
| Member constants | ||||||
| Member functions | ||||||
| Path decomposition | ||||||
| Non-member functions | ||||||
| ||||||
| Helper classes | ||||||
path& operator=(const path& p); | (1) | (since C++17) |
path& operator=( path&& p)noexcept; | (2) | (since C++17) |
path& operator=( string_type&& source); | (3) | (since C++17) |
template<class Source> path& operator=(const Source& source); | (4) | (since C++17) |
(4) participates in overload resolution only ifSource andpath are not the same type, and either:
Source is a specialization ofstd::basic_string orstd::basic_string_view, orContents |
| p | - | a path to assign |
| source | - | astd::basic_string,std::basic_string_view, pointer to a null-terminated character/wide character string, or an input iterator that points to a null-terminated character/wide character sequence. The character type must be one ofchar,char8_t,(since C++20)char16_t,char32_t,wchar_t |
*this
#include <filesystem>namespace fs= std::filesystem; int main(){ fs::path p="C:/users/abcdef/AppData/Local"; p= p/"Temp";// move assignmentconstwchar_t* wstr= L"D:/猫.txt"; p= wstr;// assignment from a source}
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3244 | C++17 | constraint thatSource cannot bepath was missing | added |
| assigns contents (public member function)[edit] | |
constructs apath(public member function)[edit] |