
I keep getting a bad_any_cast exception when I retrieve data from a map. Basically: class DataType { //protected: public: boost::any value_; DataType(){}; template <class type> DataType(type& value) : value_(value) {}; template <class type> DataType(const type& value) : value_(value) {}; // Provide constant & non constant version of operator = template <class type> type& operator=(type &rhs) { value_=rhs; return rhs; }; template <typename type> const type& operator= (const type& rhs) { value_=rhs; return rhs; }; } map <std::string, DataType> m; DataType dt; dt=3.5; m["Data 1"] = dt; DataType dt = fieldData["Data 1"]; fValue = boost::any_cast<float>(dt.value_); //returns a bad_any_cast What am I doing wrong? Joe McCay
participants (2)
-
Dan Day
-
Joe McCay