fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <functional>
  4. using namespace std;
  5.  
  6. int main (int, char**) {
  7. int object = 21; // half of the answer
  8. vector<reference_wrapper<int>> v;
  9. v.push_back(object);
  10. v[0].get() = 42; // assignment needs explicit conversion of lhs to a real reference
  11. cout << "the answer is " << object << endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
the answer is 42