A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/iterator/move_iterator/operator*/ below:

public member function

<iterator>

std::move_iterator::operator*
reference operator*() const;

Dereference iterator

Returns an rvalue reference to the element pointed by the iterator.

Internally, the function returns the result of dereferencing its base iterator casted to the appropriate rvalue reference type.

The iterator shall point to some object in order to be dereferenceable.



Parameters none

Return value An rvalue reference to the element pointed by the iterator.
Member type reference is an alias of the rvalue reference type that refers to base iterator's own value type.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// move_iterator::operator* example
#include <iostream>     // std::cout
#include <iterator>     // std::move_iterator
#include <vector>       // std::vector
#include <string>       // std::string

int main () {
  std::string str[] = {"one","two","three"};
  std::vector<std::string> foo;

  std::move_iterator<std::string*> it (str);
  for (int i=0; i<3; ++i) {
    foo.push_back(*it);
    ++it;
  }

  std::cout << "foo:";
  for (std::string& x : foo) std::cout << ' ' << x;
  std::cout << '\n';

  return 0;
}

Output:


Data races The object is accessed.
The reference returned can be used to access or modify elements.

Exception safety Provides the same level of guarantee as the operations internally applied to the base iterator.

See also
move_iterator::operator->
Dereference iterator (public member function)
move_iterator::operator[]
Dereference iterator with offset (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4