Menu

C++ development notes : about `auto`
📰

C++ development notes : about `auto`

DEV Community: cpp·David Sporn·about 7 hours ago
#3JniUA8g
#devtocpp#devto#dev#auto#rationale
Reading 0:00
15s threshold

It's been almost six monthes since I started a new C++ project with the intent of refreshing my practices for this language. Before that attempt, I stuck to a kind of "C with classes" style of programming, as it was enough to get things done (essentially, some little projects on micro-controllers).

Now I use the stl, like vectors , map , optional , expected , unique_ptr , etc...

But one feature that I want to avoid as much as possible is the auto keyword. I wrote a programming rule for myself named auto is evil .

That rule states that auto is generally banned, with one exception .

My rationale is the following :

Primary rationale : the keyword auto hides knowledge. It's bad for discovering a foreign codebase, as well as for learning the language.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.