• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <filesystem>

    std::filesystem::swap (非メンバ関数)

    namespace std::filesystem {
      void swap(path& x, path& y) noexcept;
    }
    

    概要

    2つのpathオブジェクトを入れ替える。

    効果

    x.swap(y)

    戻り値

    なし

    #include <iostream>
    #include <filesystem>
    
    namespace fs = std::filesystem;
    
    int main()
    {
      fs::path a = "/foo/a.txt";
      fs::path b = "/foo/b.md";
    
      fs::swap(a, b);
    
      std::cout << "a : " << a << std::endl;
      std::cout << "b : " << b << std::endl;
    }
    

    出力

    a : "/foo/b.md"
    b : "/foo/a.txt"
    

    バージョン

    言語

    • C++17

    処理系