Solved Templates question
-
this is a function prototype
template<class ReturnType> ReturnType getValue(const QString &t_tableName, const QString &t_columnName)
Here I am calling it
getValue<QString>("user", "name");
that is the error I get
error: no matching function for call to 'PersistantStorageSyncWorker::getValue(const char [5], const char [5]) const' return getValue<QString>("user", "name"); ^
What do I need to fix to make it work propertly?
-
@Kofr Works for me. What compiler do you use?
You could try to pass QString instances explicitly as parameters.
Also is template<class ReturnType> ReturnType getValue(const QString &t_tableName, const QString &t_columnName) defined in PersistantStorageSyncWorker namespace? -
Did you note that there is a difference in 'const' within your post?
@Kofr said in Templates question:
this is a function prototype
template<class ReturnType> ReturnType getValue(const QString &t_tableName, const QString &t_columnName)
Assuming that this is part of your class declaration, you would need:
template<class ReturnType> ReturnType getValue(const QString &t_tableName, const QString &t_columnName) const;
Also this could make a difference, but do not think that it is required.
return getValue<QString>( QStringLiteral("user"), QStringLiteral("name"));
-
the problem was with constantness