fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct some_type {};
  5.  
  6. void doSomething(some_type& model)
  7. {
  8. cout << "reference: " << &model << endl;
  9. }
  10.  
  11. void test(some_type input_model, bool do_copy)
  12. {
  13. cout << "original: " << &input_model << endl;
  14. if (do_copy)
  15. {
  16. some_type copy_model = input_model;
  17. doSomething(copy_model);
  18. }
  19. else
  20. doSomething(input_model);
  21. }
  22.  
  23. int main()
  24. {
  25. test({}, true);
  26. test({}, false);
  27. return 0;
  28. }
Success #stdin #stdout 0s 5484KB
stdin
Standard input is empty
stdout
original: 0x7fff69490480
reference: 0x7fff69490457
original: 0x7fff69490480
reference: 0x7fff69490480