Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 881 Bytes

File metadata and controls

58 lines (43 loc) · 881 Bytes

swap (非メンバ関数)

  • filesystem[meta header]
  • std::filesystem[meta namespace]
  • function[meta id-type]
  • cpp17[meta cpp]
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;
}
  • fs::swap[color ff0000]

出力

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

バージョン

言語

  • C++17

処理系