A RetroSearch Logo

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

Search Query:

Showing content from https://cplusplus.com/reference/functional/reference_wrapper/operator_typeref/ below:

public member function

<functional>

std::reference_wrapper::operator type&
operator type&() const noexcept;

Cast to reference

Returns a reference to the referred element.

type is a member type describing the referred type (it is an alias of the class template parameter, T).

This returns the same as member get.



Parameters none

Return value The referred element.

type is a member type describing the referred type (it is an alias of the class template parameter, T).



Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// reference_wrapper::operator type&
#include <iostream>     // std::cout
#include <functional>   // std::reference_wrapper

int main () {
  int foo;

  std::reference_wrapper<int> wrap (foo);

  static_cast<int&>(wrap) = 10;
  int& bar = wrap;
  ++bar;

  std::cout << foo << '\n';

  return 0;
}

Output:


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

Exception safetyNo-throw guarantee: this member function never throws exceptions.

See also
reference_wrapper::get
Access element (public member function)
reference_wrapper::operator()
Access element (functional form) (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