I\'m playing with a trick to overload lambdas in C++. Specifically:
// For std::function
#include
The original code shouldn't compile, gcc is correct here. See [class.member.lookup]:
Otherwise (i.e., C does not contain a declaration of f or the resulting declaration set is empty), S(f,C) is initially empty. If C has base classes, calculate the lookup set for f in each direct base class subobject Bi, and merge each such lookup set S(f,Bi) in turn into S(f,C).
— [..]
— Otherwise, if the declaration sets of S(f,Bi) and S(f,C) differ, the merge is ambiguous...
The initial declaration set is empty (overload
has no methods) - so merge all the bases, all of whom have differing sets. So the merge should fail. That rule only applies if the declaration set of overload
is empty though, which is why the explicit adding of the using F1::operator()
works.