Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acknowledge std::variant #268

Open
elshize opened this issue Feb 2, 2021 · 0 comments
Open

Acknowledge std::variant #268

elshize opened this issue Feb 2, 2021 · 0 comments

Comments

@elshize
Copy link

elshize commented Feb 2, 2021

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++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant