jeudi 5 décembre 2019

how to typecast a template parameter when passing to a function

How can i pass the typename value to a function which accepts a bool value , currently when i try to pass the value i get C2440 error type cast cannot convert from val to bool.

template < typename val >
void CommandInterfaceContainer::SetValue(val value)
{
    Container cont;
    cont.value( value ); // this function accepts bool value when i try to pass the value of val i get error typecast cannot convert val to bool

}

I tried to cast the value to bool but it does not work

cont.value( (bool)value );

Aucun commentaire:

Enregistrer un commentaire