If I do not write operator =, it does not compile.
This surprised me, so I looked at the standard and I found:
Your example has an implicitly deleted copy instance, but it should still compile if the appropriate C ++ 11 standard library is at hand.
The only expression that places restrictions on the type used by vector in your example is push_back .
The push_back() method of the container type of sequence X<T,A> with dispenser A and value_type T requires T :
- CopyInsertable if a lvalue or const rvalue reference is passed
- MoveInsertable if non-constant r value is passed
This means that this requires a valid copy constructor or (as in this case) a valid move constructor that will be implicitly present in your code. Therefore, compilation should not be interrupted in any compiler with a valid C ++ 11 standard library.
Operations that require the type contained in vector for assignment:
Auxiliary conditions
typdef std::vector<T> X; X a,b; X&& rv; X::value_type t; X::value_type&& u; X::size_type n; X::const_iterator p,q;
Pessimistic * list of operations
The operations that require T to be assigned if X is vector are:
Statement Requirement on T a = b; CopyInsertable, CopyAssignable a = rv; MoveInsertable, MoveAssignable a = il; CopyAssignable a.emplace(p, args); MoveInsertable, MoveAssignable a.insert(p, t); CopyAssignable a.insert(p, u); MoveAssignable a.insert(p, n, t); CopyInsertable, CopyAssignable a.insert(p, i, j); EmplaceConstructible[from *i], MoveInsertable, MoveAssignable a.insert(p, il); -> a.insert(p, il.begin(), il.end()); a.erase(q); MoveAssignable a.erase(q1,q2) MoveAssignable a.assign(i,j); Assignable from *i a.assign(il); -> a.assign(il.begin(), il.end()); a.assign(n,t) CopyAssignable
* = Pessimistic means that for the actual entry into force, certain conditions may exist for several requirements. If you use one of the expressions listed above, your type T will probably need to be assigned.