问题
I'm using JSON Spirit to parse and generate json.
I cannot use using namespace json_spirit
because another library uses conflicting names.
I'm trying to detect the type as specified here of a read message with
if(message.type() == obj_type)
but the compiler reports
error: ‘obj_type’ was not declared in this scope
if(stamper_message.type() == obj_type){
^
note: suggested alternative:
In file included from /usr/local/include/json_spirit.h:13:0:
/usr/local/include/json_spirit_value.h:32:22: note: ‘obj_type’
enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type };
I have also added this line
using json_spirit::Value_type;
and this line
typedef json_spirit::Value_type Value_type;
but it doesn't help.
I apologize for such a simple question, but I cannot find a solution, so how can this enum
be imported for use in this way?
回答1:
From a very old Q&A:
using json_spirit::Value_type;
Value_type obj_type = Value_type::obj_type;
I will delete if someone posts something better or a way to declare all enum members in one line.
来源:https://stackoverflow.com/questions/21992445/obj-type-was-not-declared-in-this-scope-note-suggested-alternative-enum-val