u/parnmattin r/programming • Recommends
On “std::visit is Everything Wrong with Modern C++”
It's a deduction guide. It is needed such that you do not need to explicit specify the template types.
This is because there is no constructor within `overloaded` which would get that deduction implied. Due to C++17 also adding aggregate initialisation of base classes, an explicit constructor isn't needed at all. My understanding is that the constructor would have (subtly) different types in the constructor's parameter pack (ensures the correct types are used), than the struct itself, so it is needed.
telling the compiler "if you see `overloaded` 'constructed' as such, it is of *this* type"
edit:
Jason Turner covered this a few years ago in Eps. 48 49, and revisited *cough* in 134 w…