I've been able to find multiple conversations about this in the past (e.g. here), but such conversations are from quite a while ago. The code I have a question about is:
#include <utility>
#include <iostream>
struct Foo
{
Foo() = default;
Foo(const Foo &o)
{
std::cout << "copy" << std::endl;
}
Foo(Foo &&o)
{
std::cout << "move" << std::endl;
}
};
struct Bar
{
Foo foo;
};
int main(void)
{
Bar a;
Bar b(a);
Bar c(std::move(a));
}
If you execute the code in Visual Studio 2013 (Update 3), it prints out "copy" for both cases. If the standard hasn't changed since the answer in the link above, then the output should be "copy" followed by "move." Ideone seems to give the correct output. Is this just something that Visual Studio hasn't implemented yet, or is there something missing in my code? I know that you cannot mark move constructors as default, but that does not imply that the compiler does not support generating default move constructors all-together.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…