std::filesystem::path::assign
来自cppreference.com
< cpp | filesystem | path
文件系统库
类 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
函数 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
文件类型 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::filesystem::path
常量 | |||||||||||||||||||||
成员函数 | |||||||||||||||||||||
|
|||||||||||||||||||||
路径分解 | |||||||||||||||||||||
非成员函数 | |||||||||||||||||||||
|
|||||||||||||||||||||
辅助类 | |||||||||||||||||||||
path&
assign(
string_type&&
source );
|
(1) | (C++17 起) |
template<
class
Source >
path& assign( const Source& source ); |
(2) | (C++17 起) |
template<
class
InputIt >
path& assign( InputIt first, InputIt last ); |
(3) | (C++17 起) |
以从给定字符序列构造的新路径替换 path
对象的内容。
1) 以受检测格式字符串
source
所标识的路径名赋值,字符串留在合法但未指定的状态。2) 以受检测格式的字符范围
source
所标识的路径名赋值。3) 以受检测格式字符范围
[first, last)
所标识的路径名赋值。(2) 仅若 Source
与 path
不是同一类型,而且:
-
Source
是 std::basic_string 或 std::basic_string_view 的特化,或 - std::iterator_traits<std::decay_t<Source>>::value_type 合法并代表可能有 const 限定的编码字符类型( char 、 char8_t 、 (C++20 起)char16_t 、 char32_t 或 wchar_t )
才参与重载决议
参数
source | - | 所用的字符范围,表示为 std::basic_string 、 std::basic_string_view 、指向空终止字符/宽字符串的指针,或是一个指向空终止字符/宽字符序列的输入迭代器 |
first, last | - | 所用的字符范围 |
类型要求 | ||
-InputIt
必须符合老式输入迭代器
(LegacyInputIterator)
的要求。
|
||
-InputIt
的 value_type 必须是编码字符类型( char
、 wchar_t
、 char16_t
及 char32_t
)之一
|
返回值
*this
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 3244 | C++17 | 缺失 Source 不能为 path 的制约
|
已添加 |
参阅
赋值另一个路径 (公开成员函数) |