I use the following code with C ++ 11 and I get an error that I am not allowed to use typeof !
What is the problem and how to fix it?
Mistake:
Error 10 error C2923: 'typeof' is not a valid template type argument for parameter 'C'
Here is my code:
#define HIBERLITE_NVP(Field) hiberlite::sql_nvp< typeof(Field) >(#Field,Field) class Person{ friend class hiberlite::access; template<class Archive> void hibernate(Archive & ar) { ar & HIBERLITE_NVP(name); //ERROR ar & HIBERLITE_NVP(age); //ERROR ar & HIBERLITE_NVP(bio); //ERROR } public: string name; double age; vector<string> bio; };
sql_nvp looks like this:
template<class C> class sql_nvp{ public: std::string name; C& value; std::string search_key; sql_nvp(std::string _name, C& _value, std::string search="") : name(_name), value(_value), search_key(search) {} };
c ++ c ++ 11 visual-c ++
Mohsen sarkar
source share