3 ms·
The reason why we have std::visit the way it is, is because that's the way it worked in Boost Variant, which is the basis for the proposal. The reason why it's
by int_19h 9y ago
The reason why we have std::visit the way it is, is because that's the way it worked in Boost Variant, which is the basis for the proposal.
The reason why it's the basis, is because it's a time-tested, proven and stable solution that has been around since 2002.
The reason why it's so ugly, is because that's the best you could do in C++ back in 2002.
So, there's a perfectly rational explanation for all this - it's not "insane". It is unfortunate that they didn't come up with a better API that would make use of new language features, but it's not like someone deliberately set down to design the more convoluted older API just to confuse people.