std::experimental::filesystem::path::append, (3) Linux Manual Page
std::experimental::filesystem::path::append, – std::experimental::filesystem::path::append,
Synopsis
path &operator/=(const path &p);
(1)(filesystem TS)
template <class Source>
(2)(filesystem TS)
path &
operator/=(const Source &source);
template <class Source>
(3)(filesystem TS)
path &append(const Source &source);
template <class InputIt>
(4)(filesystem TS)
path &append(InputIt first, InputIt last);
1)
following conditions is true:
*
*
some other way
*
*
Then, appends p.native()
2,3)
string, or an input iterator pointing to a null-terminated multicharacter sequence.
4)
string.
Parameters
p
source
first, last
Type requirements
–
InputIt must meet the requirements of LegacyInputIterator.
–
The value type of InputIt must be one of the encoded character types
char16_t and char32_t)
Return value
*this
Exceptions
May throw filesystem_error on underlying OS API errors or std::bad_alloc if memory
allocation fails.
Example
// Run this code
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p1 = "C:";
p1 /= "Users"; // does not insert a separator
// "C:Users" is a relative path in Windows
// adding directory separator would turn it to an absolute path
std::cout << "\"C:\" / \"Users\" == " << p1 << '\n';
p1 /= "batman"; // inserts fs::path::preferred_separator, '\' on Windows
std::cout << "\"C:\" / \"Users\" / \"batman\" == " << p1 << '\n';
}
Possible output:
See also
concat concatenates two paths without introducing a directory separator
operator+= (public member function)
operator/ concatenates two paths with a directory separator
(function)
