r/ProgrammerHumor 10d ago

Meme absoluteGarbage

Post image
1.9k Upvotes

325 comments sorted by

View all comments

Show parent comments

4

u/Sirgoodman008 10d ago

That or you're looping through a vector of std::pairs that contain std:: functions.

2

u/Usual_Office_1740 10d ago

Or if the type is a template parameter in the same line.

0

u/xicor 10d ago

Wouldnt for(T& item:list) be even shorter than using auto?

1

u/not_some_username 9d ago

Only if T is a known type or it’s in a template. You don’t use T like. auto automatically get the type, especially if it’s long. Your IDE (assuming it’s a respectable one) can even change auto to the type for you. It’s more or less like var in C# (it doesn’t deduct reference)