І have a bool variable named do_copy.
If do_copy == true, I want to work with a copy, like
some_type model = input_model
If do_copy == false, I want to work with a reference, like
some_type& model = input_model
Code that does what I want:
some_type copy_model;
if (do_copy)
copy_model = input_model;
some_type& model = do_copy ? copy_model : input_model;
It does not look very good, and I call the default constructor, which isn't necessary for do_copy == false.
Is there a way to make it more elegant?