>> moveable m;
>> m = get_moveable();
Change that to
auto m = get_moveable();
and enable optimizations. The former might work if the compiler is smart enough.
Also, remove "void" from the empty parameter lists.
EDIT:
Code:
struct moveable
{
moveable()
{
std::cout << "invoking default constructor\n";
}
moveable(moveable const& rhs) = delete;
moveable(moveable&& rhs)
{
std::cout << "invoking move constructor\n";
}
auto operator=(moveable&& rhs) -> moveable&
{
std::cout << "invoking move assignment operator\n";
return *this;
}
};
auto get_moveable() -> moveable
{
moveable m;
return m;
}
int main()
{
auto m = get_moveable();
return 0;
}
Output:
invoking default constructor