A RetroSearch Logo

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

Search Query:

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

public member function

<iterator>

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

Dereference iterator

Returns a reference to the element pointed by the iterator.

Internally, the function returns the value the object stores as its current element.

If the iterator has just been constructed from an input stream, and the implementation of that operation did not extract a value form the stream on construction, it is now extracted.

If the iterator is an end-of-stream iterator it shall not be dereferenced.



Parameters none

Return value A constant reference to the element pointed by the iterator.
Member type reference is an alias of const value_type&, where value_type is the type of the elements extracted by the operator (the first class template parameter).

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// istream_iterator example
#include <iostream>     // std::cin, std::cout
#include <iterator>     // std::istream_iterator

int main () {
  double value1, value2;
  std::cout << "Please, insert two values: ";

  std::istream_iterator<double> eos;              // end-of-stream iterator
  std::istream_iterator<double> iit (std::cin);   // stdin iterator

  if (iit!=eos) value1=*iit;

  ++iit;
  if (iit!=eos) value2=*iit;

  std::cout << value1 << "*" << value2 << "=" << (value1*value2) << '\n';

  return 0;
}

Data races The object is accessed (certain library implementations may also modify it).
The reference returned can be used to access elements.

Exception safetyStrong guarantee: if an exception is thrown, there are no changes in the visible state of the iterator.

See also
istream_iterator::operator->
Dereference iterator (public member function)
istream_iterator::operator++
Increment iterator position (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