gcc fails to compile this code, but clang compiles it well.
According to this gcc is right. Because there is several base classes with the same function name - operator()
, which is an ambiguity
Is it really clang bug? Or may be there is special lookup rules for operator()
in standard or something else not so obvious?
#include <utility>
template <class... Ts>
class TMultiLambda: public Ts... {
public:
template <class... Fs>
TMultiLambda(Fs&&... Vs) noexcept: Ts(std::forward<Fs>(Vs))... {
}
};
template <class... Ts>
auto MakeMultiLambda(Ts&&... Vs) noexcept -> TMultiLambda<std::remove_reference_t<Ts>...> {
return { std::forward<Ts>(Vs)... };
}
int main() {
int x;
auto a = [x](int, int) { };
auto b = [x] (char) { };
auto c = MakeMultiLambda(a, b);
c(2, 2);
c('q');
return 0;
}
P.S.
You can compile code online here, do not forget to append -std=c++1y
to compiler options