#include
struct A { int a[100]; };
void foo (const A& a) {
std::vector vA;
vA.push_back(std::move(a)); // how does move really happen
Created a snippet to show it. Though in your example default constructor will be called, but you get the idea.
#include
#include
struct A {
int a[100];
A() {}
A(const A& other) {
std::cout << "copy" << std::endl;
}
A(A&& other) {
std::cout << "move" << std::endl;
}
};
void foo(const A& a) {
std::vector vA;
vA.push_back(std::move(a));
}
void bar(A&& a) {
std::vector vA;
vA.push_back(std::move(a));
}
int main () {
A a;
foo(a); // "copy"
bar(std::move(a)); // "move"
}