# std::move_iterator<Iter>::base

> C++ Atlas: `cppatlas.com/w/cpp/iterator/move_iterator/base` | Source: https://en.cppreference.com/w/cpp/iterator/move_iterator/base | Domain: Iterator | Standards: C++11, C++17, C++20

Returns the underlying iterator.

## Official Specification Summary (cppreference)

```cpp
iterator_type base() const; // (1) (constexpr since C++17) (until C++20)
constexpr const iterator_type& base() const& noexcept; // (1) (since C++20)
constexpr iterator_type base() &&; // (2) (since C++20)
```

Returns the underlying iterator.

1) Returns a copy of (until C++20) reference to (since C++20) the underlying iterator.

2) Returns an iterator move constructed from the underlying iterator.

### Return value

1) `current`

2) `std::move(current)`

### Example

```cpp
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>

int main()
{
    std::vector<int> v{0, 1, 2, 3, 4};
    std::move_iterator<std::vector<int>::reverse_iterator>
        m1{v.rbegin()},
        m2{v.rend()};

    std::copy(m1.base(), m2.base(), std::ostream_iterator<int>(std::cout, " "));
    std::cout << '\n';
}
```

Output:

```text
4 3 2 1 0
```

### Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

| DR | Applied to | Behavior as published | Correct behavior |
| --- | --- | --- | --- |
| LWG 3391 | C++20 | overload (1) returned a copy of the underlying iterator | returns a reference |
| LWG 3593 | C++20 | overload (1) was not noexcept | made noexcept |

### See also

- [`operator*`](https://en.cppreference.com/w/cpp/iterator/move_iterator/operator*) (C++11), [`operator->`](https://en.cppreference.com/w/cpp/iterator/move_iterator/operator*) (C++11)(deprecated in C++20): accesses the pointed-to element (public member function)

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