I’d hate to ask an intentionally subjective question on here, but I don’t have anyone else to ask this directly…
I’m trying to “lead by example” in my team by adopting more modern C++ concepts in new code I write. My coworkers are a bit shy of templates, and gripe about having to type unique_ptr<Foobar> or shared_ptr<Foobar> instead of just Foobar* when utilizing some classes I’ve recently created (factory methods return unique_ptrs and I store lists of these objects in vectors using shared_ptr).
They twisted my arm and convinced me to typedef these into something easier to type, eg FoobarUniquePtr.
But now I’m in a mess of const-correctness with these typedefs. I’d have to define extra typedefs for each const and non const type, and const const_FoobarUniquePtr doesn’t seem to properly express the const semantics.
So, to my question, would it make sense to stop using these typedefs and instead shove auto at my teammates when they complain about having to type the templated smart pointers? I’m also open to other alternatives.
In general, auto makes your life a lot easier.
If you aren’t shipping on any esoteric architectures (and have no plans to do so anytime soon), the answer should be “use auto whenever you can”.