void swap (stack& x) noexcept(/*see below*/);
*this
noexcept
1234567891011121314151617
// stack::swap #include <iostream> // std::cout #include <stack> // std::stack int main () { std::stack<int> foo,bar; foo.push (10); foo.push(20); foo.push(30); bar.push (111); bar.push(222); foo.swap(bar); std::cout << "size of foo: " << foo.size() << '\n'; std::cout << "size of bar: " << bar.size() << '\n'; return 0; }
size of foo: 2 size of bar: 3