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

履歴 編集

function
<filesystem>

std::filesystem::path::swap(C++17)

void swap(path& x) noexcept;

概要

他のpathオブジェクトとデータを入れ替える。

効果

*thisの内容をxと交換する。

戻り値

なし

計算量

定数時間

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
  fs::path a = "/foo/a.txt";
  fs::path b = "/foo/b.md";

  a.swap(b);

  std::cout << "a : " << a << std::endl;
  std::cout << "b : " << b << std::endl;
}

出力

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

バージョン

言語

  • C++17

処理系