Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Templates question
Forum Updated to NodeBB v4.3 + New Features

Templates question

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by
    #1

    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?

    jsulmJ K 2 Replies Last reply
    0
    • K Kofr

      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?

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Kofr

        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?

        K Offline
        K Offline
        koahnig
        wrote on last edited by VRonin
        #3

        @Kofr

        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"));
        

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        3
        • K Offline
          K Offline
          Kofr
          wrote on last edited by
          #4

          the problem was with constantness

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved