|
list::operator=public member function
list<T,Allocator>& operator= ( const list<T,Allocator>& x ); Copy container content Assigns as the new content for the container a copy of the elements in x.The elements contained in the object before the call are dropped, and replaced by copies of those in vector x, if any. After a call to this member function, both the list object and x will have the same size and compare equal to each other. Parameters
Return value*thisExample
Both list containers of int elements are initialized to sequences with different sizes. Then, second is assigned to first, so both are now equal and with a size of 3. And then, first is assigned to a newly constructed empty container object, so its size is finally 0. Output:
ComplexityLinear on sizes (destruction, copy construction).See also
|