最終更新日時(UTC):
が更新

履歴 編集

function
<functional>

std::reference_wrapper::get(C++11)

T& get() const noexcept;            //C++11

constexpr T& get() const noexcept;  //C++20

概要

生参照を取得する

戻り値

保持している参照を返す

例外

投げない

#include <iostream>
#include <functional>

int main()
{
  int x = 3;

  std::reference_wrapper<int> r(x);
  int& rx = r.get(); // 参照を取得する
  rx += 1;

  std::cout << x << std::endl;
}

出力

4

バージョン

言語

  • C++11

処理系

参照