Why doesn't this use of emplace_back with deleted copy constructor work?

When the vector's internal storage grows, it will need to move the elements from the old storage to the new. By deleting the copy constructor, you also prevent it generating the default move constructor.


To be able to call emplace_back, your type should either be EmplaceConstructible or MoveInsertible . You need to give a move constructor to your class if you have deleted the copy constructor. (Check this for requirements of emplace_back)

 MyType(MyType &&a) {/*code*/} //move constructor