Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Typically you should pass raw pointers (constness depends on your use case...). I can't really think of a scenario where the method/function needs to be coupled with the pointer type.


I will often have functions that accept a unique_ptr as a parameter. This way, I can clearly encode that the object belongs to the callee now.


And if you are wanting to pass the raw pointer, you should probably pass by & instead as well. The only real "features" of raw pointers over references are the ability to reassign or delete them, and if you are passing something by reference, you do not want anyone doing any such thing to it 99.9% of the time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: