Gnollrunner said:
I would say no. C++ features are not nearly as important is knowing algorithms and data structures. Modern C++ is mostly the addition of the standard library. There are some new things and some of them are even handy like move semantics. On the other hand sometimes modern C++ can blind you to things that you would know if you learned C++ by going up thought the ranks of learning C, old C++ and Modern C++ in that order.
I completely disagree. The difference, for example between:
const std::vector<int>::iterator end = elements.end();
for (std::vector<int>::iterator itr = elements.begin(); itr != elements.end(); ++itr)
{
std::cout << *itr;
}
and
for (const auto element : elements)
{
std::cout << element;
}
for example, is absolutely game-changing. Sure, not every feature between c++98 and c++23 is that mind-boggling, but between lambdas, string_view, concepts, variadic templates etc… are all things that have much more impact on your overall productivity then just knowing about vector and list and when to use which.
taby said:
Do not use the auto keyword. You’re only obfuscating your code when you use it.
I also completely disagree on this. In 95% of places where you write the type, is doesn't matter. Especially when dealing with iterators or other complex templates, typing the fully qualified name is a huge waste of space, and can even decrease readability. I'm personally a huge fan of almost always auto, but I guess you can overdo it - but saying “do not use auto” is absolutely not warranted. For example, whats the point of having the type here:
void collisionResponse(std::span<Entity*> entities)
{
//for (Entity* pEntity : entities)
for (auto* pEntity : entities)
{
pEntity->DoSomething();
}
}
It doesn't add anything of value - you literally have the type of the container one line above, the name is already explanatory enough; if somebody doesn't know what an entity is in the context of the code reading the type won't matter (and if he does, he'll likely know mostly based on the variable-name). I'd be willing to compromise that using “auto” might obfuscate the code when its used where the actual type cannot be inferred from the surrounding source (which should be rather rare) - and that only for the sake of being able to read the code in source-control, because IDEs will already fill in the missing information while coding anyways.