std::filesystem::path::make_preferred

Converts all directory separators in the generic-format view of the path to the preferred directory separator.

# Declarations

path& make_preferred();

(since C++17)

# Return value

*this

# Example

#include <filesystem>
#include <iostream>
 
int main()
{
    std::filesystem::path
        windows_path("a\\b\\c"),
        posix_path("a/b/c");
 
    std::cout
        << "Windows path: "
        << windows_path << " -> "
        << windows_path.make_preferred() << '\n'
        << "POSIX path: "
        << posix_path << " -> "
        << posix_path.make_preferred() << '\n';
}