vendredi 12 février 2021

std::function in std::unordered_map, error C3867 non-standard syntax; use '&' to create a pointer to member

I try to replace if/else by using a map to call some api

why the initializer list throws the error?

...
#include <functional>
#include <unordered_map>

class MyClass final : public Base
{
   std::string InfoInquiry(Class_1& request, Class_2& response);
   std::string ActivateDeactivate(Class_1& request, Class_2& response);
   ...
   using Callback = std::function<std::string(Class_1&, Class_2&)>;
   const std::unordered_map<std::string, Callback> m_ApiCalbacks{ //error C3867: 'MyClass ::InfoInquiry': non-standard syntax; use '&' to create a pointer to member
      {"INFO", InfoInquiry},
      {"ACTIVATE_DEACTIVATE", ActivateDeactivate},
      ...
   };
}

Aucun commentaire:

Enregistrer un commentaire