#include <iostream>
class Test
{
public:
Test()
{ std::cout << "Test::Test()" << std::endl; }
Test (const Test& rhs)
{ std::cout << "Test::Test (const Test&)" << std::endl; }
Test (Test&& rhs)
{ std::cout << "Test::Test (Test&&)" << std::endl; }
Test& operator= (const Test& rhs)
{ std::cout << "Test::operator= (const Test&)" << std::endl; return *this; }
Test& operator= (Test&& rhs)
{ std::cout << "Test::operator= (Test&&)" << std::endl; return *this; }
};
Test immediate_return()
{
return Test();
}
Test local_variable()
{
Test local;
return local;
}
Test local_variable_and_assignment()
{
Test local = Test();
return local;
}
int main()
{
Test a;
Test b = Test();
Test c = immediate_return();
Test d = local_variable();
Test e = local_variable_and_assignment();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgVGVzdAp7CnB1YmxpYzoKCglUZXN0KCkKCQl7IHN0ZDo6Y291dCA8PCAiVGVzdDo6VGVzdCgpIiA8PCBzdGQ6OmVuZGw7IH0KCglUZXN0IChjb25zdCBUZXN0JiByaHMpCgkJeyBzdGQ6OmNvdXQgPDwgIlRlc3Q6OlRlc3QgKGNvbnN0IFRlc3QmKSIgPDwgc3RkOjplbmRsOyB9CgoJVGVzdCAoVGVzdCYmIHJocykKCQl7IHN0ZDo6Y291dCA8PCAiVGVzdDo6VGVzdCAoVGVzdCYmKSIgPDwgc3RkOjplbmRsOyB9CgoJVGVzdCYgb3BlcmF0b3I9IChjb25zdCBUZXN0JiByaHMpCgkJeyBzdGQ6OmNvdXQgPDwgIlRlc3Q6Om9wZXJhdG9yPSAoY29uc3QgVGVzdCYpIiA8PCBzdGQ6OmVuZGw7IHJldHVybiAqdGhpczsgfQoKCVRlc3QmIG9wZXJhdG9yPSAoVGVzdCYmIHJocykKCQl7IHN0ZDo6Y291dCA8PCAiVGVzdDo6b3BlcmF0b3I9IChUZXN0JiYpIiA8PCBzdGQ6OmVuZGw7IHJldHVybiAqdGhpczsgfQp9OwoKVGVzdCBpbW1lZGlhdGVfcmV0dXJuKCkKewoJcmV0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