I was trying to reply to another answer and I found some difficulties while playing with lambdas and inheritance. Consider the following, minimal example:
template<typename Func>
struct Base: Func {
Base(Func func): Func{func} {}
template<typename... Args>
auto operator()(Args... args)
-> decltype(Func::operator()(args...), void()) {
Func::operator()(args...);
}
};
int main() {
auto l = [](auto &&) {};
Base<decltype(l)> mixin{l};
mixin(0);
}
GCC 6.1 compiles it, clang 4.0 crashes (see https://godbolt.org/z/6Gz5s66h5). Note that both compile just fine using the following definition:
auto l = [](int) {};
Is this valid code or I'm doing something that is not allowed by the standard?
I've reported this as LLVM bug 31356, though I'd still like to know whether my code is correct.
print " \n"
, but I think a crash is a better QOI. ;) – Jannet