#include <iostream>
#include <utility>
struct A
{
A() = default;
A(A const&) { std::cout << "A(A const&)" << std::endl; }
A(A&&) { std::cout << "A(A&&)" << std::endl; }
};
struct B { A a; ~B() = default; };
struct C { A a; };
int main()
{
auto b1 = B{};
auto b2 = B(std::move(b1)); // A(A const&) is called.
auto c1 = C{};
auto c2 = C(std::move(c1)); // A(A&&) is called.
}
See online demo
Why does a default destructor change the move-semantics?
Aucun commentaire:
Enregistrer un commentaire