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)。
目录 |
[编辑] 参数
| source | - | - 要使用的字符范围,表示为 std::string、std::string_view、指向空终止多字节字符串的指针,或作为 value_type 为字符类型的输入迭代器,指向一个空终止多字节字符串 |
| first, last | - | - 要使用的字符范围 |
| 类型要求 | ||
-InputIt 必须满足 LegacyInputIterator 的要求。 | ||
-InputIt 的 value_type 必须是编码字符类型之一(char、wchar_t、char16_t 及 char32_t) | ||
[编辑] 返回值
*this
[编辑] 缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 发布时的行为 | 正确的行为 |
|---|---|---|---|
| LWG 3244 | C++17 | 缺少 Source 不能是 path 的约束 |
已添加 |
[编辑] 参阅
| 赋值另一个路径 (公开成员函数) |