#include <iostream>
struct Bar {
Bar() { std::cout << "create\n"; }
Bar(Bar const&) { std::cout << "copy\n"; }
Bar(Bar&&) { std::cout << "move\n"; }
~Bar() { std::cout << "destroy\n"; }
};
void fooA(Bar const& bar) {
Bar bar_cpy(bar);
}
void fooB(Bar bar) {
}
int main() {
::std::cout << "by-reference then copy\n";
fooA(Bar());
::std::cout << "\nby-value\n";
fooB(Bar());
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEJhciB7CglCYXIoKSB7IHN0ZDo6Y291dCA8PCAiY3JlYXRlXG4iOyB9CglCYXIoQmFyIGNvbnN0JikgeyBzdGQ6OmNvdXQgPDwgImNvcHlcbiI7IH0KCUJhcihCYXImJikgeyBzdGQ6OmNvdXQgPDwgIm1vdmVcbiI7IH0KCX5CYXIoKSB7IHN0ZDo6Y291dCA8PCAiZGVzdHJveVxuIjsgfQp9OwoKdm9pZCBmb29BKEJhciBjb25zdCYgYmFyKSB7CglCYXIgYmFyX2NweShiYXIpOwp9Cgp2b2lkIGZvb0IoQmFyIGJhcikgewp9CgppbnQgbWFpbigpIHsKCTo6c3RkOjpjb3V0IDw8ICJieS1yZWZlcmVuY2UgdGhlbiBjb3B5XG4iOwoJZm9vQShCYXIoKSk7CgkKCTo6c3RkOjpjb3V0IDw8ICJcbmJ5LXZhbHVlXG4iOwoJZm9vQihCYXIoKSk7Cn0=