std::experimental::filesystem::path::append, std::experimental::filesystem::path::operator/=
Min standard notice:
- First, appends the preferred directory separator to this, except if any of the following conditions is true:
# Declarations
path& operator/=( const path& p );
(filesystem TS)
template< class Source >
path& operator/=( const Source& source );
(filesystem TS)
template< class Source >
path& append( const Source& source );
(filesystem TS)
template< class InputIt >
path& append( InputIt first, InputIt last );
(filesystem TS)
# Parameters
p: pathname to appendsource: std::basic_string, 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 LegacyInputIterators that specify a multicharacter sequence that represents a path name
# Return value
*this
# Example
#include <experimental/filesystem>
#include <iostream>
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';
}