I would like to know if doing the following is safe:
template<class T>
void Parameters::add(Parameter<T> p)
{
std::string sprobe("");
int iprobe = 0;
double dprobe = 0.;
if (typeid(T) == typeid(sprobe))
this->mstrings[p.name()] = p;
if (typeid(T) == typeid(iprobe))
this->mints[p.name()] = p;
if (typeid(T) == typeid(dprobe))
this->mdoubles[p.name()] = p;
}
I have a Class for storing parameters. It has 3 boost::unordered_map member variables for storing parameters of type int, double and std::string;
I created a template class Parameter.
I understand that if my Parameter is not one of the 3 types that I anticipated this will fail. But it is not a problem since I know that the Parameters can only be of these types.
Thanks for your help