Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 752397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:46:36+00:00 2026-05-14T14:46:36+00:00

I have coworkers who occasionally use typedef to avoid typing. For example: typedef std::list<Foobar>

  • 0

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?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:46:36+00:00Added an answer on May 14, 2026 at 2:46 pm

    The two big arguments for this type of typedef are the reduced typing, which you’ve already mentioned, and the ease of changing over to a new type of container. A FoobarList could be backed by a vector or a list or a deque and switching would often just require changing a typedef.

    Your dislike of them when it comes to looking them up, is quite reduced when dealing with IDEs, since I can just hover over the type name, and the IDE tells me what it’s defined as.

    The more useful situations are when you have nested containers – you can give the names some semantic meaning without having to define entire classes:

    typedef std::list<Foobar> FoobarList;
    typedef std::map <string, FoobarList> GizmosToFoobarsMap;
    

    You can also save a LOT of typing when dealing with iterators of these types (although that’s reduced now that C++0x has auto.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this example on StackOverflow: var people = new List<Person> { new
I'd like to introduce Maven to my fellow coworkers who mostly use Ant to
I have a coworker who writes unit tests for objects which fill their fields
I have a coworker who is looking to switch from InteilliJ Idea to Eclipse,
My Google-fu is failing me on this question. I have a coworker who has
I have a localization issue. One of my industrious coworkers has replaced all the
I was having a discussion with coworkers. We have to implement some security standards.
My coworker and I have encountered a nasty situation where we have to use
I have a program that posts Datetime.Now(), but my coworkers computer's DateTime.Now() is off
Have an app that can use tts to read text messages. It can also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.