# std::basic_ios<CharT,Traits>::swap

> C++ Atlas: `cppatlas.com/w/cpp/io/basic_ios/swap` | Source: https://en.cppreference.com/w/cpp/io/basic_ios/swap | Domain: Input/output | Standards: C++11

Exchanges the states of *this and other, except for the associated rdbuf objects. rdbuf() and other.rdbuf() returns the same values as before the call.

## Official Specification Summary (cppreference)

```cpp
protected:
void swap( basic_ios& other ) noexcept; // (since C++11)
```

Exchanges the states of `*this` and `other`, except for the associated `rdbuf` objects. `rdbuf()` and `other.rdbuf()` returns the same values as before the call.

This swap function is protected: it is called by the swap member functions of the derived stream classes such as `std::basic_ofstream` or `std::basic_istringstream`, which know how to correctly swap the associated stream buffers.

### Parameters

- `other` - the `basic_ios` object to exchange the state with

### See also

- [`move`](https://en.cppreference.com/w/cpp/io/basic_ios/move) (C++11): moves from another `std::basic_ios` except for `rdbuf` (protected member function)

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