On Saturday, 5 October 2019 at 04:07:45 UTC, Meta wrote:
I'm not sure if you're aware, but funnily enough, I also wrote an article[1] on std::variant vs. the D alternative that references Matt Kline's article on std::visit. It seems we're really making getting our money's worth from his article.

I really enjoyed this - I think you're right in that it comes down to the complexity of implementation, and I suspect that C++ forced the developers of std::variant to choose between a usable API (usable, not good) and performance.

I remember seeing your article when it went up on the D blog. It's a great illustration of how things that are complex in C++ are often easy or even trivial in D.

Some of the commenters on reddit brought up boost.variant2 and mpark::variant as alternative C++ implementations that generate the same code as C. So it's clearly *possible* for C++ to get good performance on this. It's just that in C++, you have to work really hard for it, whereas in D, it's so easy you'd have to work harder to get it wrong.

Reply via email to