3 ms·
You could consider using any of the already existing sum type libraries like boost::variant. The code will certainly be more verbose than ML, but still better
by gpderetta 11y ago
You could consider using any of the already existing sum type libraries like boost::variant.
The code will certainly be more verbose than ML, but still better than roll-your-own.
- loup-vaillant 11y agoAnd manage another significant dependency. If boost::variant was as nice as ML, I would do it. But it's not. I'm not sure this is worth the trouble.
- gpderetta 11y agoIf you are already using boost, as many projects are, it is no extra dependency. Otherwise there are many standalone implementations. Egg.Variant is an high quality one: https://github.com/eggs-cpp/variant https://github.com/eggs-cpp/variant . We are likely going to get a std variant type in the next standard, either as a library component or as a language feature.