std::filesystem::path::concat
文件系统::path::conat,std::file system::path::Operator+=
path& operator+=( const path& p | (1) | (since C++17) |
---|---|---|
path& operator+=( const string_type& str path& operator+=( std::basic_string_view<value_type> str | (2) | (since C++17) |
path& operator+=( const value_type* ptr | (3) | (since C++17) |
path& operator+=( value_type x | (4) | (since C++17) |
template< class Source > path& operator+=( const Source& source | (5) | (since C++17) |
template< class CharT > path& operator+=( CharT x | (6) | (since C++17) |
template< class Source > path& concat( const Source& source | (7) | (since C++17) |
template< class InputIt > path& concat( InputIterator first, InputIterator last | (8) | (since C++17) |
连接当前路径和参数。
1%29名Concatenates*this
和p
以这样的方式本地人%28%29结果完全是原创的本地人%28%29与...连在一起p.native()
2%29与%281%29相同,但结果除外本地人%28%29是原始{的连接。本地人%28%29和字符串%28或字符串视图%29str
3%29与%281%29相同,但结果除外本地人%28%29是原本地人%28%29和第一个字符指向的以空结尾的字符串。ptr
4%29与%281%29相同,但结果除外本地人%28%29是原本地人%28%29和单字x
5%29与%281%29相同,但结果除外本地人%28%29是原本地人%28%29和序列%28,该序列可以是可移植的或本机格式的%29,所表示的source
,这可能是std::basic_string
,,,std::basic_string_view
或指向空终止多字符序列的输入迭代器.
6%29与%284%29相同,但可以执行字符转换
7%29与%285%29
8%29与%285%29相同,但该序列由指定多字符字符串的任何迭代器对表示。
参数
p | - | path to append |
---|---|---|
str | - | string or string view to append |
ptr | - | pointer to the beginning of a null-terminated string to append |
x | - | single character to append |
source | - | std::basic_string, std::basic_string_view, null-terminated multicharacter string, or an input iterator pointing to a null-terminated multicharacter sequence, which represents a path name (either in portable or in native format) |
first, last | - | pair of InputIterators that specify a multicharacter sequence that represents a path name |
类型要求
-输入必须符合输入器的要求。
-InputIt的值类型必须是编码字符类型%28 char,wchar[医]T,char16[医]T和char32[医]t%29
图表必须是编码字符类型%28 char,wchar[医]T,char16[医]T和char32[医]t%29
返回值
*this
...
例外
可抛filesystem_error
关于基础OS API错误或std::bad_alloc
如果内存分配失败。
注记
不像append()
或operator/=
,则从不引入附加的目录分隔符。
例
二次
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
fs::path p1; // empty path
p1 += "var"; // does not insert a separator
std::cout << "\"\" + \"var\" == " << p1 << '\n';
p1 += "lib"; // does not insert a separator
std::cout << "\"\" + \"var\" + \"lib\" == " << p1 << '\n';
}
二次
产出:
二次
"" + "var" == "var"
"" + "var" + "lib" == "varlib"
二次
另见
appendoperator/= | appends elements to the path with a directory separator (public member function) |
---|---|
operator/ | concatenates two paths with a directory separator (function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。