Yes, but very limited in practice since the standard containers are mostly not usable.
It works for plain arrays… so, at least there’s that.
C++ is confusing, ugly, and so overwrought with features it is ridiculous. And… I admit, C++ is probably the world’s second worst system implementation language… THE worst is, of course, C.
So far, kernel C++ is not helping save time for code reviews, hampers readability, and without most of powerful library stuff and coding patterns based on that stuff, it is pointless.
That sounds like a statement from somebody who has not much tried using it, within some reasonable bounds.
Strong type checking, by itself, is sufficient reason to write your code in pretty much standard C and add a .cpp file type.
Also,”constexpr” is undoubtedly an improvement over #define, and we use it this way as much as possible.
There are some very good cases for using std::unique_ptr as well, and (in general) RAII classes that “automatically destruct” when they go out of scope. It’s not something I use in every driver that I write, but — given that I firmly believe try/finally is an evil construct — when I have something that needs allocation, initialization, use, and then some complex destruction at the end of the function… it can be super handy. The challenge to this in a driver that is otherwise pretty much normal C is writing enough in-line documentation to prevent future maintainers from going nuts. There’s also the problem of one person’s “it would be tidy to make an RAII class of this here” is another person’s “I can’t believe they added all this shite and made the code more complex! Just clean-up properly at the end of the function!”
It’s OK… we’ll all be writing drivers in Rust soon, so we won’t have to have this debate much longer. (Picture me rolling my eyes and shaking my head as you read that last sentence… Its meant to be a joke, not an insider hint.)
Peter