I have a function in which i am receiving a string values .
Based on the value i want to create a variable.
Template<typename T>
void func( std::string str , T value )
{
if( str == "int" )
{
int val = value;
}
if( str == "double" )
{
double val = value;
}
if( str == "string" )
{
std:string val = value;
}
}
is it possible to automate this function , instead of having lot of if conditions ?
Aucun commentaire:
Enregistrer un commentaire