std::filesystem::path::assign
来自 cppreference.cn
< cpp | 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
标识的路径名,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)。
内容 |
[edit] 参数
source | - | 要使用的字符范围,表示为 std::string, std::string_view, 指向空终止多字节字符串的指针,或作为具有 char 值类型的输入迭代器,指向空终止多字节字符串 |
first, last | - | 要使用的字符范围 |
类型要求 | ||
-InputIt 必须满足 LegacyInputIterator 的要求。 | ||
-InputIt 的值类型必须是编码字符类型之一 (char, wchar_t, char16_t 和 char32_t) |
[edit] 返回值
*this
[edit] 缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。
DR | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
LWG 3244 | C++17 | 约束 Source 不能为 path 缺失 |
已添加 |
[edit] 参见
赋值另一个路径 (公共成员函数) |