3 ms·
Just asking because I'm curious: What are the parts of C++ that you actually use? To me RAII and managed pointers are by far the most useful features in C++, fo
by oriolid 4y ago
Just asking because I'm curious: What are the parts of C++ that you actually use? To me RAII and managed pointers are by far the most useful features in C++, followed by templates (think of them as type safe macros with slightly less horrible syntax, not as generics).
- rsaxvc 4y agoNot the commenter but embedded embedded here so my perspective is a little different. For me, constexpr for resolving complex build-time logic into constants, cleaner type handling for the math library makes it harder to accidentally pull in a 64-bit libm when we only have a 32- it FPU, and templating for sure. It's pretty easy in C to reach a point where macros of macros is madness but templates calling templates still works with the debugger and is a powerful mechanism for hoisting complexity out of loops. Also works nicely for writing outer loops once in c++ calling a template specialized to either inline assembly or c++. Managed pointers sometimes but our team seems pretty good with object lifetimes from a C background, and we don't use too much heap anyway. RTTI and exceptions we often disable to save code space. RAII is a little tricky without exceptions, we often use it's easy.
- oriolid 4y agoGood point about embedded, smart pointers aren't that great when you try to avoid allocating memory at runtime and never free it anyway. RAII is still useful for managing other lifetimes, though. The last time I worked on embedded stuff the compiler we used generated often larger code for constexpr, so we didn't really use it.
- intelVISA 4y agoAbout the same here: RAII > smart pointers > constexpr > templates > coro in that order.
- 5636553454654 4y agoThis is similar to me. As far as modern stuff, I'm willing go upto c++20, and I use smart pointers, templates, constexpr, RAII, and STL. With templates, I use them for generics, but also judiciously to create meta-linguistic abstractions to get around certain limitations of language. For example, I built an ORM using them. I don't use auto, or lambdas, or even foreach (I use iterators), despite oddly having much more dynamic language experience.