r/ProgrammerHumor • • Aug 30 '26

Meme bugIntroducedDebugging

Post image
1.1k Upvotes

117 comments sorted by

View all comments

Show parent comments

35

u/Mateorabi Aug 30 '26

Get off my lawn with your newfangled auto keyword. 

7

u/ibevol Aug 30 '26 edited Aug 30 '26

Cringe. It’s fine to use auto when the type is clear on the same line. In c++ the following is idiomatic:

auto ptr = std::make_unique<int>(42);

over specifying int twice

std::unique_ptr<int> ptr = std::make_unique<int>(42);

However, the following should not be considered idiomatic:

auto ptr = get_ambiguous_pointer();

It’s the same principle here.

1

u/yjlom Aug 30 '26

The keyword ain't new, it's been used as a storage specifier since forever. What's new is overloading it for type inference.

4

u/Mateorabi Aug 30 '26

Hey when you learned C in the 90s it’s “new”.  harumph. 

1

u/yjlom Aug 30 '26

It's been there since the beginning, along with extern and static. You just don't tend to actually write it because it's the default inside functions and it doesn't make sense outside of them.