I am trying to initialise an (unordered) map in my .hpp header file that has integer keys and member function pointer values:
// in Test.hpp
#include <unordered_map>
class Test {
private:
std::unordered_map<int, void(*)()> tst = {
{1, foo}
};
void foo();
};
Compilation gives
test.hpp:10:2: error: could not convert ‘{{1, ((Test*)this)->Test::foo}}’ from ‘<brace-enclosed initializer list>’ to ‘std::unordered_map<int, void (*)()>’
};
^
How should I alter this or is such an initialisation not possible in the header file?