You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I'm trying to get or find a enum struct but I get a compilation error.
error: no matching function for call to 'nlohmann::basic_json<>::at(const ns::m_struct::m_enum_struct&) const
error: no matching function for call to 'std::map<std::__cxx11::basic_string<char>, nlohmann::basic_json<>, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::basic_json<> > > >::find(const ns::m_struct::m_enum_struct&)
This is the function where I get the error
voidmyClass::getValue(constenum m_struct::m_enum_struct v){
staticconst nlohmann::json j = {
{ns::m_struct::m_enum_struct::a,500},
{ns::m_struct::m_enum_struct::b,2000}
};
int p;
if(j.find(v) != j.end()){ //error
p = j.at(v); //error
}else{
p = 0;
}
}
this is how I implement my objects, to_json and from_json:
namespacens{
structm_struct{
enumstructm_enum_struct {
a = 2,
b = 5,
c = 7
};
};
voidfrom_json(const nlohmann::json & j, enum m_struct::m_enum_struct & v){
v = static_cast<enum m_struct::m_enum_struct>(std::stoi(j.get<std::string>()));
}
voidto_json(nlohmann::json& j, constenum m_struct::m_enum_struct & v){
j = nlohmann::json{std::to_string(static_cast<int>(v))};
}
}
I'm using gcc 6.4.0 and working from v 3.3.0 of the develop branch
EDIT: fixed typos
The text was updated successfully, but these errors were encountered:
Hello
Currently I'm trying to get or find a enum struct but I get a compilation error.
This is the function where I get the error
this is how I implement my objects, to_json and from_json:
I'm using gcc 6.4.0 and working from v 3.3.0 of the develop branch
EDIT: fixed typos
The text was updated successfully, but these errors were encountered: