How can I get this working? (C++17/20)
Note: I have to use std::invoke
here because in the real code, the only guarantee I have is that this callable is invokable.
#include <bits/stdc++.h> // to include everything
int main() {
const auto func = [&]<typename T>(const std::string& h) {
T t;
std::cout << t << " " << h << "\n";
};
std::invoke(func<std::string>, std::string("Hello"));
}
Error:
<source>:17:33: error: expected primary-expression before '>' token
17 | std::invoke(func<std::string>, std::string("Hello"));