Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
std::function copies
#include <iostream> #include <functional> struct alma { alma() { std::cout << "default ctor\n"; } alma(const alma& rhs) { std::cout << "copy ctor\n"; } alma(alma&& rhs) { std::cout << "move ctor\n"; } alma& operator=(const alma& rhs) { std::cout << "copy assignement\n"; return *this; } alma& operator=(alma&& rhs) { std::cout << "move assignement\n"; return *this; } }; using callable = std::function<void()>; int main() { alma a; alma b=a; alma c; c = b; alma d{std::move(c)}; alma e; e = std::move(d); std::cout << "==========\n"; callable x = [e] () { }; std::cout << "==========\n"; callable y; std::cout << "==========\n"; y = x; std::cout << "==========\n"; }
run
|
edit
|
history
|
help
0
C++ Standard Template Library
How to test call member?
Recursive Function Calling Example with Stack Addresses
STL stack
hw 1 os
user defined exception
range based for loop temporary object lifetime issue example
Move Construction
BucketSort
bubble sort