- string[meta header]
- std[meta namespace]
- function template[meta id-type]
namespace std {
template <class CharT, class Traits, class Allocator>
void swap(basic_string<CharT, Traits, Allocator>& x,
basic_string<CharT, Traits, Allocator>& y);
template <class CharT, class Traits, class Allocator>
void swap(basic_string<CharT, Traits, Allocator>& x,
basic_string<CharT, Traits, Allocator>& y)
noexcept(noexcept(lhs.swap(rhs))); // C++17
}
2つのbasic_string
オブジェクトを入れ替える
x.
swap
(y)
なし
#include <iostream>
#include <string>
int main()
{
std::string a = "hello";
std::string b = "world";
std::swap(a, b);
std::cout << a << std::endl;
std::cout << b << std::endl;
}
- std::swap[color ff0000]
world
hello
- N4258 Cleaning-up noexcept in the Library, Rev 3
noexcept
追加の経緯となる提案文書