Given the following type view, how can I initialize Fields with some std::pair s?
template <> struct ManagerDataTrait<Person> { static const std::unordered_map<std::string, std::string> Fields;
I tried using lambda, but Visual Studio says that Fields not an object that can be explicitly specialized.
template <> const std::unordered_map<std::string, std::string> ManagerDataTrait<Person>::Fields = []{ std::unordered_map<std::string, std::string> fields; fields.insert(std::make_pair("height", "FLOAT")); fields.insert(std::make_pair("mass", "FLOAT")); return fields; };
If there is no way to use static members like this in outline, what alternatives do I need to store in the value? ( Fields contains the SQL database structure.)
Update: A member can also be const , but this should not be a point.
c ++ unordered-map typetraits static-members template-specialization
danijar
source share