# std::basic_ospanstream<CharT,Traits>::operator=

> C++ Atlas: `cppatlas.com/w/cpp/io/basic_ospanstream/operator=` | Source: https://en.cppreference.com/w/cpp/io/basic_ospanstream/operator= | Domain: Input/output | Standards: C++11, C++23

Note that move assignment operator of the base class swaps all stream state variables (except for rdbuf()) between *this and other.

## Official Specification Summary (cppreference)

```cpp
basic_ospanstream& operator=( basic_ospanstream&& other ); // (1) (since C++23)
basic_ospanstream& operator=( const basic_ospanstream& ) = delete; // (2) (since C++23)
```

1) Move assigns the `other` to `*this`, effectively move-assigning both the `std::basic_ostream` base class subobject and the wrapped `std::basic_spanbuf`.

2) Copy assignment operator is deleted. `basic_ospanstream` is not copy assignable.

Note that move assignment operator of the base class swaps all stream state variables (except for `rdbuf()`) between `*this` and `other`.

It is implementation-defined whether the `std::basic_spanbuf` wrapped in `other` still holds an underlying buffer after the move assignment.

### Parameters

- `other` - another stream to move from

### Return value

`*this`

### Exceptions

May throw implementation-defined exceptions.

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`operator=`](https://en.cppreference.com/w/cpp/io/basic_spanbuf/operator=): assigns a `basic_spanbuf` object (public member function of `std::basic_spanbuf<CharT,Traits>`)
- [`operator=`](https://en.cppreference.com/w/cpp/io/basic_ostream/operator=) (C++11): move-assigns from another `basic_ostream` (protected member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/io/basic_ospanstream/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.