std::experimental::filesystem::path::append, std::experimental::filesystem::path::operator/=

  1. 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

# 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';
}

# See also