Proper use of of typedef in C++
- by dicroce
I have coworkers who occasionally use typedef to avoid typing. For example:
typedef std::list<Foobar> FoobarList;
...
FoobarList GetFoobars();
Personally, I always hate coming across code like this, largely because it forces me to go lookup the typedef so I can tell how to use it. I also feel like this sort of thing is a potential slippery slope... If you do this, why aren't you doing it more? (pretty soon, your code is totally obfuscated). I found this SO question regarding this issue:
when should I use typedef in C
I have two questions: 1) am I truly alone in disliking this? 2) If the vast majority of people think this sort of typedef use is OK, what criteria do you use to determine whether to typedef a type?