deque::operator= | public member function |
deque<T,Allocator>& operator= ( const deque<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 deque x, if any.
After a call to this member function, both the deque and x will have the same size and compare equal to each other.
Parameters
- x
- A deque object containing elements of the same type.
Return value
*thisExample
// assignment operator with deques #include <iostream> #include <deque> using namespace std; int main () { deque<int> first (3); // deque with 3 zero-initialized ints deque<int> second (5); // deque with 5 zero-initialized ints second=first; first=deque<int>(); cout << "Size of first: " << int (first.size()) << endl; cout << "Size of second: " << int (second.size()) << endl; return 0; } |
Size of first: 0 |
Complexity
Linear on sizes (destruction, copy construction).See also
deque::assign | Assign container content (public member function) |