Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
move swap
#include <iostream> #include <utility> using namespace std; struct Foo { Foo() = default; Foo(const Foo &) { cout << "copy ctor" << endl; } Foo(Foo &&) { cout << "move ctor" << endl; } Foo &operator=(const Foo &) { cout << "copy =" << endl; return *this; } Foo &operator=(Foo &&) { cout << "move =" << endl; return *this; } }; int main() { Foo a, b; cout << "swap(a, b)" << endl; swap(a, b); cout << "swap(move(a), move(b))" << endl; swap(move(a), move(b)); return 0; }
run
|
edit
|
history
|
help
0
123
hangman
reference
Test
thread-destructor
std::current_exception makes a copy
Matrix_1
cv4_template
7
du