Код: Выделить всё
#include
#include
#include
#include
class Test
{
private:
std::any cb_;
public:
template
void foo(T cb)
{
cb_ = cb;
}
template
void bar(T... arg)
{
std::any_cast(cb_)(arg...);
}
};
void test(int a)
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79148444/how-to-use-stdany-to-store-an-callable-object[/url]