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

履歴 編集

function
<functional>

std::reference_wrapper::operator T&(C++11)

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

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

概要

生参照への変換

戻り値

保持している参照を返す

例外

投げない

#include <iostream>
#include <functional>

int main()
{
  int x = 3;

  std::reference_wrapper<int> r(x);
  int& rx = r; // 参照に暗黙変換する
  rx += 1;

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

出力

4

バージョン

言語

  • C++11

処理系

参照