#include <utility>
#include <tuple>
template < typename T, typename U >
void h(T, U)
{
}
template < typename... T, typename... U >
void f(std::tuple < T... > t, std::tuple < U... > u)
{
auto g = [&] < std::size_t... I > (std::index_sequence < I... >)
{
bool const r[]{((void)h(std::get < I >(t), std::get < I >(u)), false)...};
(void)r;
};
g(std::index_sequence_for < T... >());
}
int main()
{
f(std::make_tuple(0L, 0LL), std::make_tuple(0UL, 0ULL));
}
The above compiles with g++ test_templated_lambda.cpp -o test_templated_lambda -std=c++14
, but doesn't compile with clang++ test_templated_lambda.cpp -o test_templated_lambda -std=c++14
I know it is a GCC extension (Using template parameter in a generic lambda), but is there some way to do this without writing out g
as a free function