Reputation: 7687
The following wont compile (tried both clang & gcc)
#include <vector>
struct Foo
{
Foo(int a=0) : m_a(a) {}
Foo(const Foo& f) = delete;
// Foo(Foo&& f) = default;
private:
int m_a;
};
int main()
{
std::vector<Foo> foovec;
foovec.emplace_back(44); // might resize, so might move
}
But if I don't delete the copy constructor, or if I default the move constructor,
it will work. So, does deleting copy constructor suppress move constructor,
and what is the rational behind that?
Upvotes: 4
Views: 1450
Reputation: 903
You should see table about special class members. When you set copy constructor as a deleted one move constructor won't be generated automatically.
See more in table:
Upvotes: 12