fork download
  1. #include <iostream>
  2. #include <cassert>
  3. #include <functional>
  4. using namespace std;
  5.  
  6. int main() {
  7. double a = 5.;
  8. double b = 3.;
  9. double& ref = a;
  10. ref = b;
  11. assert(&ref != b); // ref is not bound to b
  12. std::reference_wrapper<double> refwpr = a;
  13. refwpr = b;
  14. assert(&refwpr.get() == b); // ref wrapper was rebound to b
  15. return 0;
  16. }
Success #stdin #stdout 0s 3452KB
stdin
Standard input is empty
stdout
Standard output is empty