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?
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:
Source (slides).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With