3 ms·
Not necessarily. The types may just have very long names. In C++ for iterating through STL container auto is a godsend. The types are very straightforward and e
by maxxxxx 8y ago
Not necessarily. The types may just have very long names. In C++ for iterating through STL container auto is a godsend. The types are very straightforward and easy to reason about but just long.
for (auto it = s.begin(); it != s.end(); it++) {
is much easier to write than
for (vector<int>::iterator it = s.begin(); it!=s.end(); it++) {
- jschwartzi 8y agoI try to avoid using STL because it A) throws exceptions, B) has really convoluted type names, and C) dynamically allocates memory. These are all things you avoid in the embedded space.
- maxxxxx 8y agoMakes sense for embedded.
- gowld 8y agoAny use of templates has the same problem, including templates that are used to generate highly efficient static constants and non-branching-at-runtime code.
- llukas 8y agoExample? Templates (template metaprogramming) help to avoid exceptions. You can check invariants first and jump into efficient code.
- llukas 8y agoor almost like python: for (auto &element: s){ even better with structured bindings: for (auto [key, value]: map){