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

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

Sets the associated stream buffer to sb without clearing the error state.

## Official Specification Summary (cppreference)

```cpp
protected:
void set_rdbuf( std::basic_streambuf<CharT,Traits>* sb ); // (since C++11)
```

Sets the associated stream buffer to `sb` without clearing the error state.

This member function is protected: it is called by the move constructors of the derived streams such as `std::basic_ofstream` or `std::basic_istringstream`, as the final step after constructing the base class and after moving the stream buffer: only the most derived stream class knows how to correctly move the stream buffer, but `std::basic_ios` needs to be made aware of the stream's new location so that its public member functions can access it.

### Parameters

- `sb` - stream buffer to associate to

### Return value

(none)

### Exceptions

Throws nothing.

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`rdbuf`](https://en.cppreference.com/w/cpp/io/basic_ios/rdbuf): manages associated stream buffer (public member function)

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