- expected[meta header]
- function[meta id-type]
- std[meta namespace]
- unexpected[meta class]
- cpp23[meta cpp]
friend constexpr void swap(unexpected& x, unexpected& y)
noexcept(noexcept(x.swap(y)));- x.swap(y)[link swap.md]
2つのunexpectedオブジェクトを入れ替える。
x.swap(y);- swap[link swap.md]
なし
#include <cassert>
#include <expected>
#include <utility>
int main()
{
std::unexpected<int> x{1};
std::unexpected<int> y{2};
assert(x.error() == 1 && y.error() == 2);
std::swap(x, y);
assert(x.error() == 2 && y.error() == 1);
}- std::swap[color ff0000]
- error()[link error.md]
- std::unexpected[link ../unexpected.md]
- C++23
- Clang: 16.0 [mark verified]
- GCC: 12.1 [mark verified]
- Visual C++: ??