I would also add some variations of this old question, although they can be very controversial ...
Like OldPeculier's answer, I like short type names that resemble standard pointers as closely as possible.
In a project that used shared_pointer almost everywhere, I used
typedef boost::shared_ptr<Foo> Foo_;
I took advantage of three things:
- The underscore somehow looks like an operator, but is basically treated as a letter, so it can be part of the identifier (and I see it at the end of the identifier that does not prohibit the rule ).
- I needed only one typedef.
- I prefer
Foo* myFoo1; by Foo *myFoo1; for several reasons, and it goes well with Foo_ myFoo2 .
When you need typedefs for different kinds of smart pointers, I would go for
typedef shared_ptr<Foo> Foo_S; typedef weak_ptr<Foo> Foo_W; typedef unique_ptr<Foo> Foo_U;
With the increasing support for Unicode in compiler standards and implementations, I will be tempted to try the following syntax, assuming that these star characters will be treated as a regular part of the type identifier. Of course, this is practical if for all involved developers there is a convenient way to enter text:
typedef shared_ptr<Foo> Foo★; typedef weak_ptr<Foo> Foo☆; typedef unique_ptr<Foo> Foo✪;
(A quick test showed that this really does not work, at least with my build environment. But the same is true for Foo_ä .)
Lena Schimmel Jun 20 '17 at 9:42 on 2017-06-20 09:42
source share