# std::stack<T,Container>::operator=

> C++ Atlas: `cppatlas.com/w/cpp/container/stack/operator=` | Source: https://en.cppreference.com/w/cpp/container/stack/operator= | Domain: Containers | Standards: C++98, C++11

Replaces the contents of the container adaptor with the contents of given argument.

## Official Specification Summary (cppreference)

```cpp
stack& operator=( const stack& other ); // (1) (implicitly declared)
stack& operator=( stack&& other ); // (2) (since C++11) (implicitly declared)
```

Replaces the contents of the container adaptor with the contents of given argument.

1) Copy assignment operator. Replaces the contents with a copy of the contents of `other`. Effectively calls `c = other.c;`.

2) Move assignment operator. Replaces the contents with those of `other` using move semantics. Effectively calls `c = std::move(other.c);`.

### Parameters

- `other` - another container adaptor to be used as source

### Return value

`*this`

### Complexity

1,2) Equivalent to that of `operator=` of the underlying container.

### Example

> Note: This section is incomplete Reason: no example

### See also

- [(constructor)](https://en.cppreference.com/w/cpp/container/stack/stack): constructs the `stack` (public member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/container/stack/operator= (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.