#include <iostream>
struct A
{
A( ) { }
A( const A& ) { std:: cout << "A::copy_constructor is called to make a copy\n " ; }
A( A&& ) { std:: cout << "in this program, this message will not be printed\n " ; }
} ;
void foo( A object ) { std:: cout << "foo has recieved a copy of an object\n " ; }
A bar( ) { std:: cout << "bar - about to return an object by value\n " ; static A a ; return a ; }
int main( )
{
std:: cout << "about to call bar\n " ;
A object = bar( ) ;
std:: cout << "bar has returned\n " ;
std:: cout << "\n \n about to call foo\n " ;
foo( object) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnN0cnVjdCBBCnsKICAgIEEoKSB7fQogICAgQSggY29uc3QgQSYgKSB7IHN0ZDo6Y291dCA8PCAiQTo6Y29weV9jb25zdHJ1Y3RvciBpcyBjYWxsZWQgdG8gbWFrZSBhIGNvcHlcbiIgOyB9CiAgICBBKCBBJiYgKSB7IHN0ZDo6Y291dCA8PCAiaW4gdGhpcyBwcm9ncmFtLCB0aGlzIG1lc3NhZ2Ugd2lsbCBub3QgYmUgcHJpbnRlZFxuIiA7IH0KfTsKIAp2b2lkIGZvbyggQSBvYmplY3QgKSB7IHN0ZDo6Y291dCA8PCAiZm9vIGhhcyByZWNpZXZlZCBhIGNvcHkgb2YgYW4gb2JqZWN0XG4iICA7IH0KQSBiYXIoKSB7IHN0ZDo6Y291dCA8PCAiYmFyIC0gYWJvdXQgdG8gcmV0dXJuIGFuIG9iamVjdCBieSB2YWx1ZVxuIiA7IHN0YXRpYyBBIGEgOyByZXR1cm4gYSA7IH0KIAppbnQgbWFpbigpCnsKICAgIHN0ZDo6Y291dCA8PCAiYWJvdXQgdG8gY2FsbCBiYXJcbiIgOwogICAgQSBvYmplY3QgPSBiYXIoKSA7CiAgICBzdGQ6OmNvdXQgPDwgImJhciBoYXMgcmV0dXJuZWRcbiIgOwogCiAgICBzdGQ6OmNvdXQgPDwgIlxuXG5hYm91dCB0byBjYWxsIGZvb1xuIiA7CiAgICBmb28ob2JqZWN0KSA7Cn0KIA==