path::swap



#include <filesystem>
#include <iostream>
                                                                                                         
using std::filesystem::path,
    std::cerr;

int main(){
    char buffer[20]{"/home/temp.txt\0"};
    path p1(buffer);
    char buf[20]{"/home/temp.html\0"};
    path p2(buf);
    cerr << "p1: " << p1.string() << "\n";
    cerr << "p2: " << p2.string() << "\n";
    p1.swap(p2);
    cerr << "swap\n";
    cerr << "p1: " << p1.string() << "\n";
    cerr << "p2: " << p2.string() << "\n";

    return 0;
}      
C++ Examples© 2024 TBD