Getting back up to speed with modern C++ after a couple years writing rust really makes me appreciate what a nicely designed language rust is. Some thoughts as I go…
'At the application level, abstractions relying on such tagged unions are common and useful. The use of “naked” unions is best minimized.'

Strong agreement there, but I only just learned that C++ stdlib *has* a tagged union type (equivalent to rust's enum).
It's apparently called "variant", so for the declaration:

variant<Node*,int> v;

you'd check it like:

if (holds_alternative<int>(v)) { … }

which is fine, I guess, but wow: "holds_alternative"? That's such an awful name.
Making enumerations have significantly different semantics with type safety according to whether they're declared with `enum` or `enum class` seems like a tidy encapsulation of what I find most troubling abut C++.
Extreme lol at the concept of proper modules being introduced in C++20.

Then again, better late than never.
A choice quote in the chapter on error handling and exceptions:

"In well-designed code try-blocks are rare."

I agree, but probably not for the reason the author thinks.
Reading about C++'s function overloading and default arguments reminds me how little I've missed those features in rust. Why do they seem necessary in languages like C++ and Java?
"The return type of a function can be deduced from its return value"

I had recently learned of the addition of `auto` for variable declarations; didn't think about using it for functions. This seems like maybe not such a good idea, though…
"…should be used carefully because a deduced type does not offer a stable interface: a change to the implementation of the function (or lambda) can change the type"

Ahhhh, thats the C++ I expect.
You can follow @AnoYaro.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: