Код: Выделить всё
#include
#include
template
void foo(T1& t, std::function f)
{
t = f();
}
int main() {
std::string s;
foo(s, (std::function) []() { return "a"; });
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78163545/passing-lambda-where-stdfunction-is-expected-doesnt-work-in-template-argument[/url]
Мобильная версия