logoalt Hacker News

sltkr • today at 5:26 PM • 1 reply • view on HN

Isn't the obvious choice std::variant<>?

It is kind of annoying to use, but at least there is an obvious default choice.


Replies

foldr • today at 5:59 PM

I take your point about it being the default, but IMO std::variant is pretty much unusable for a parse tree. It could work for small unions that you visit once in a while, but traversing a nested tree of std::variant types is just a disaster. It somehow manages to be comprehensively worse than using manually tagged unions in all aspects except safety.