Possible Duplicate:
Should I pass a shared_ptr by reference?
Passing smart pointers as arguments
Should I pass it by value or by constant reference? I have read numerous rules of thumb on whether to pass a copy constructible object by value or by constant reference. Such as:
- pass objects by constant reference and built in types by value (except function objects)
- pass by value unless size of the object (including dynamic memory) is less than 2 * size of a double.
Could you explain how do these rules apply to std::shared_ptr<Resource>
? I understand that the object is probably very small, likely a pointer and a reference counter, but it is still an object. What is the best practice here?