You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In section 5.6 Coproduct, there is the first mention of C++ union and how they are not tagged unions, and later it mentions boost::variant. However, we've had std::variant for a while now, so it might be a good idea to mention that.
Later on, when talking about sum types (6.2), it says:
You will rarely see union used as a sum type in C++ because of severe limitations [...] You can't even put a std::string into a union.
Though indeed I variants are definitely not as common as inheritance, this paragraphs ignores the fact that you can easily define a sum type with std::variant in C++17 and up, and you can put std::string in it as well.
If anything, I would say something like:
You rarely see unions in C++ because of the lack of pattern matching support in the language.
Anyway, it's not a big deal but it could be misleading for someone who isn't familiar with C++.
The text was updated successfully, but these errors were encountered:
In section 5.6 Coproduct, there is the first mention of C++ union and how they are not tagged unions, and later it mentions
boost::variant
. However, we've hadstd::variant
for a while now, so it might be a good idea to mention that.Later on, when talking about sum types (6.2), it says:
Though indeed I variants are definitely not as common as inheritance, this paragraphs ignores the fact that you can easily define a sum type with
std::variant
in C++17 and up, and you can putstd::string
in it as well.If anything, I would say something like:
Anyway, it's not a big deal but it could be misleading for someone who isn't familiar with C++.
The text was updated successfully, but these errors were encountered: