dimanche 8 septembre 2019

Templated function not able to convert argument

I am getting error c2664 when i call the "void CommandInterfaceFont::SetValue(plug* geom, std::string stdstrParamName, T value)" templated function.

cannot convert argument 3 from 'fieldType' to 'T'

I am not able to figure out why this error is happening.

The class SumCommandInterface has a templated function.

template<typename plugin, typename fieldType>
inline void  SumCommandInterface::setFontPluginParam(plugin* geom, std::string paramName, fieldType val)
{   
    if (geom->GetType() == "FontTexture")
    {
        CommandInterfaceFont commandInterface;
        SumFont* fnt = (SumFont*)geom;
        if(paramName == "TEXT" )
            commandInterface.SetValue< SumFont , std::string >(fnt, paramName, val);  // Get error here
        else if(paramName == "USESHADOW")
            commandInterface.SetValue< SumFont, bool >(fnt, paramName, true);   // Get error here
    }
}

This function calls the other templated function from another class.

template <typename plug , typename T >
    void CommandInterfaceFont::SetValue(plug* geom, std::string stdstrParamName, T value)
    {
        switch (lookUpMap[stdstrParamName])
        {
        case::FontParam::TEXT:
            geom->setText(value);
            break;
        case::FontParam::USESHADOW:
            geom->setUseShadow(value);
        default:            
            break;
        }
    }

Aucun commentaire:

Enregistrer un commentaire