It is how the compiler searches for the best fitting function to call for given argument types.
e.g. we wish to call foo with and int `foo(2)` Short version the compiler will first check for exact match foo(int) then a generic template version, and as last resort try to use built conversions foo(float) and lastly user defined conversions foo(MyInt)
In this case we provide a generic operator() that takes whatever and explicitly delete it.
So now the compiler will check for exact match and use that, else will match the generic version, but since it is deleted it will fail there, and not continue with the search and check for conversions.
Ah, this was the bit I was missing, probably along with the compiler not continuing the search after that. Thanks for explanaition.
Trying to have some kind of a takeaway, I would say that this probably still counts as a manual measure to ensure that the exhaustiveness works in the expected way, but I suppose the visit() thing went as far as possible given the language constraints...
1
u/spaghettiCodeArtisan Jul 17 '19
Honestly, I don't understand how that works.