JG Question
1. What are the performance and correctness implications of the following function declaration? Explain.
void f( shared_ptr<widget> );
Guru Question
2. A colleague is writing a function f that takes an existing object of type widget as a required input-only parameter, and trying to decide among the following basic ways to take the parameter (omitting const):
void f( widget& ); void f( unique_ptr<widget> ); void f( unique_ptr<widget>& ); void f( shared_ptr<widget> ); void f( shared_ptr<widget>& );
Under what circumstances is each appropriate? Explain your answer, including where const should or should not be added anywhere in the parameter type.
(There are other ways to pass the parameter, but we will consider only the ones shown above.)
JG Question