Hacker News new | past | comments | ask | show | jobs | submit login

Smart pointers realy need a native way to be specified, similar to how we use & to declare references and * for pointers. Filling your code with shared_ptr<Something> and the likes is just not going to win the majority over, even if it's useful.



A common way is having a "using FooPtr = shared_ptr<Foo>" somewhere and then only use FooPtr. This also reduces the occurrences in that word cloud.


> This also reduces the occurrences in that word cloud

Ah, yes, very good point.


Nowadays, you can do:

    auto sh_ptr = make_shared(....); // Since C++11
or

    auto uniq_ptr = make_unique(....); // Since C++14
It saves you from having to explicitly name the type parameter and you just need to pass in the parameters of the constructor. It's not as terse as & or *, but it's not that bad.


I agree it's made C++ a bit verbose, though something like the using keyword helps (which is 30 spots below typedef!)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: