fork download
  1. #include <vector>
  2. #include <iostream>
  3.  
  4. #include <functional>
  5.  
  6. int main()
  7. {
  8. int x(1);
  9.  
  10. std::vector<std::reference_wrapper<int>> v;
  11. v.push_back(std::reference_wrapper<int>(x));
  12.  
  13. x = 6;
  14.  
  15. std::cout << v.at(0); // 6
  16. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
6