- filesystem[meta header]
- std::filesystem[meta namespace]
- path[meta class]
- function[meta id-type]
- cpp17[meta cpp]
path& operator+=(const path& x); // (1)
path& operator+=(const string_type& x); // (2)
path& operator+=(basic_string_view<value_type> x); // (3)
path& operator+=(const value_type* x); // (4)
path& operator+=(value_type x); // (5)
template <class Source>
path& operator+=(const Source& x); // (6)
template <class EcharT>
path& operator+=(EcharT x); // (7)
パス文字列を加算する。
この演算子は、operator/=
と違って、ディレクトリ区切り文字を自動的に挿入はせず、パス文字列への加算のみを行う。
path(x).
native()
を、*this
が保持するパス文字列に加算する。
*this
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
{
fs::path p = "foo";
p += "bar";
std::cout << p << std::endl;
}
{
fs::path p = "foo/";
p += "bar";
std::cout << p << std::endl;
}
{
fs::path p = "foo";
p += U'p'; // UTF-32文字を加算 (文字コードはクラス内部で自動変換される)
std::cout << p << std::endl;
}
}
"foobar"
"foo/bar"
"foop"
- C++17
- Clang:
- GCC: 8.1
- Visual C++: 2017 Update 7