Can anyone tell me whether this ...
#include <memory>
using namespace std;
int main()
{
auto f = []<typename T>() -> T
{
return 123;
};
f.operator ()<int>();
}
... is the only way to call the C++20 generic lambda without arguments?
Yes, it's the only way to call them.
If the lambda can be changed, consider using a tag:
template <typename> struct tag {};
auto f = []<typename T>(tag<T>) {...};
f(tag<int>{});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With