- fstream[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
template <class CharT, class Traits>
void swap(basic_filebuf<CharT, Traits>& x,
basic_filebuf<CharT, Traits>& y); // (1) C++11
}2つのbasic_filebufオブジェクトの値を交換する。
x.swap(y)と等価
なし
#include <iostream>
#include <fstream>
int main()
{
{
std::filebuf out;
out.open("a.txt", std::ios_base::out);
out.sputn("A", 1);
}
{
std::filebuf out;
out.open("b.txt", std::ios_base::out);
out.sputn("B", 1);
}
std::filebuf a;
a.open("a.txt", std::ios_base::in);
std::filebuf b;
b.open("b.txt", std::ios_base::in);
std::swap(a, b);
std::cout << static_cast<char>(a.sbumpc()) << std::endl;
std::cout << static_cast<char>(b.sbumpc()) << std::endl;
}- std::swap[color ff0000]
- std::filebuf[link /reference/fstream/basic_filebuf.md]
- out.open[link open.md]
- a.open[link open.md]
- b.open[link open.md]
- out.sputn[link /reference/streambuf/basic_streambuf/sputn.md]
- a.sbumpc()[link /reference/streambuf/basic_streambuf/sbumpc.md]
- b.sbumpc()[link /reference/streambuf/basic_streambuf/sbumpc.md]
B
A
- C++11