名稱空間
變體
操作

std::experimental::filesystem::path::concat, std::experimental::filesystem::path::operator+=

來自 cppreference.com
< cpp‎ | experimental‎ | fs‎ | path
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件2 (併發TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
 
 
path& operator+=( const path& p );
(1) (filesystem TS)
path& operator+=( const string_type& str );
(2) (filesystem TS)
path& operator+=( const value_type* ptr );
(3) (filesystem TS)
path& operator+=( value_type x );
(4) (filesystem TS)
template< class Source >
path& operator+=( const Source& source );
(5) (filesystem TS)
template< class CharT >
path& operator+=( CharT x );
(6) (filesystem TS)
template< class Source >
path& concat( const Source& source );
(7) (filesystem TS)
template< class InputIt >
path& concat( InputIterator first, InputIterator last );
(8) (filesystem TS)

連線當前路徑和引數。

1) 連線 *thisp,使得結果的 native() 恰好是原始 native() 連線 p.native()
2)(1),但結果的 native() 是原始 native() 和字串 str 的連線。
3)(1),但結果的 native() 是原始 native() 和由 ptr 指向的以 null 結尾字串的連線。
4)(1),但結果的 native() 是原始 native() 和單個字元 x 的連線。
5)(1),但結果的 native() 是原始 native() 和由 source 表示的序列(可以是可移植或原生格式)的連線,source 可以是 std::basic_string、以 null 結尾的多字元字串,或指向以 null 結尾的多字元序列的輸入迭代器。
6)(4),但可能執行字元轉換。
7)(5)
8)(5),但序列由指定多字元字串的任何迭代器對錶示。

目錄

[編輯] 引數

p - 要附加的路徑
str - 要附加的字串
ptr - 指向要附加的以 null 結尾字串開頭的指標
x - 要附加的單個字元
source - std::basic_string、以 null 結尾的多字元字串,或指向以 null 結尾的多字元序列的輸入迭代器,表示路徑名(可移植或原生格式)
first, last - 指定表示路徑名的多字元序列的 LegacyInputIterator
型別要求
-
InputIt 必須滿足 LegacyInputIterator 的要求。
-
InputIt 的值型別必須是編碼字元型別之一(charwchar_tchar16_tchar32_t)。
-
CharT 必須是編碼字元型別之一(charwchar_tchar16_tchar32_t)。

[編輯] 返回值

*this

[編輯] 異常

如果底層 OS API 錯誤或記憶體分配失敗,可能會丟擲 filesystem_errorstd::bad_alloc

[編輯] 注意

append()operator/= 不同,永遠不會引入額外的目錄分隔符。

[編輯] 示例

#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::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"

[編輯] 參閱

向路徑追加元素
(public member function) [編輯]
用目錄分隔符連線兩個路徑
(function) [編輯]