|
Boost Users : |
From: Joe McCay (joemccay_at_[hidden])
Date: 2006-04-26 22:17:42
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net