public member function
<functional>

std::reference_wrapper::get

type& get() const noexcept;
Access element
Returns a reference to the referred element.

引數



返回值

The referred element.

type 是一個描述被引用型別的成員型別(它是類模板引數 T 的別名)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// reference_wrapper::get
#include <iostream>     // std::cout
#include <functional>   // std::reference_wrapper

int main () {
  int i;

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

  foo.get() = 10;

  std::cout << foo.get() << '\n';

  return 0;
}

輸出
10


資料競爭

該物件被訪問。
The reference returned can be used to access or modify the referred element.

異常安全

無異常保證:此成員函式從不丟擲異常。

另見