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

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

Move assigns the file stream other to *this, effectively move-assigning both the std::basic_istream base class and the associated std::basic_filebuf.

## Official Specification Summary (cppreference)

```cpp
basic_ifstream& operator=( basic_ifstream&& other ); // (since C++11)
```

Move assigns the file stream `other` to `*this`, effectively move-assigning both the `std::basic_istream` base class and the associated `std::basic_filebuf`.

`other` is left with no associated file. Note that the base class move assignment swaps all stream state variables (except for `rdbuf`) between `*this` and `other`.

### Parameters

- `other` - file stream to move

### Return value

`*this`

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`swap`](https://en.cppreference.com/w/cpp/io/basic_ifstream/swap) (C++11): swaps two file streams (public member function)
- [`operator=`](https://en.cppreference.com/w/cpp/io/basic_filebuf/operator=) (C++11): assigns a `basic_filebuf` object (public member function of `std::basic_filebuf<CharT,Traits>`)
- [`operator=`](https://en.cppreference.com/w/cpp/io/basic_istream/operator=) (C++11): move-assigns from another `basic_istream` (protected member function)

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