For c++20 it is proposed to add the following syntax for generic lambdas p0428r2.pdf
auto f = []<typename T>( T t ) {};
But the current implementation in gcc 8 did not accept the following instantiation:
f<std::string>("");
Is that a implementation bug in gcc or a missing language feature? I know we talk about a proposal and not a approved specification.
Complete example ( with comparison to template function syntax ):
template <typename T> void n( T t ) { std::cout << t << std::endl; }
auto f = []<typename T>( T t ) { std::cout << t << std::endl; };
int main()
{
f<std::string>("Hello"); // error!
n<std::string>("World");
}
complains with following error:
main.cpp:25:22: error: expected primary-expression before '>' token
f("Hello");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…