The following code snippet (compiled using gcc 6.3.0 on OS X with -std = C ++ 17) demonstrates my puzzle:
#include <experimental/tuple> template <class... Ts> auto p(Ts... args) { return (... * args); } int main() { auto q = [](auto... args) { return (... * args); }; p(1,2,3,4); // == 24 q(1,2,3,4); // == 24 auto tup = std::make_tuple(1,2,3,4); std::experimental::apply(q, tup); // == 24 std::experimental::apply(p, tup); // error: no matching function for call to 'apply(<unresolved overloaded function type>, std::tuple<int, int, int, int>&)' }
Why can I successfully apply the output to lambda, but not calling the template function? This is the expected behavior, and if so, why?
c ++ lambda templates c ++ 17
Randombits
source share