#include <iostream>
#include <functional>
#include <vector>
using namespace std;
class Red {
public:
template <typename F, typename M>
void addToVector(F f, M m)
{
//---------------------------vvvvvvv----------->changed this
list.push_back([=](){ return (m->*f)(); });
cout<<"Function added.";
}
std::vector<std::function<void()>> list;
};
class Blue {
public:
Blue()
{
r.addToVector(&Blue::someFunc, this);
}
void someFunc(){
cout<<"Some print.";
}
Red r;
};
int main()
{
Blue b;
return 0;
}