Let's say I have a class X
that does not have any type of constructor unless an implicit default constructor:
class X
{
public:
int value;
X(void) = default;
X(int) = delete;
X(const X&) = delete;
X(X&&) = delete;
};
When I make a vector out of this, std::vector<X>
, and try to push_back(X())
or emplace_back()
an element to it, the program will not compile because it tries to use the move constructor (from what I understand of the error description).
C2280 'X::X(X &&)': attempting to reference a deleted function
How can I make push_back
or emplace_back
use the default constructor?