Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. C++11 make_tuple() has 'too many arguments' in QT but not Visual Studio

C++11 make_tuple() has 'too many arguments' in QT but not Visual Studio

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 3.4k Views
  • 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.
  • R Offline
    R Offline
    RBrNx277
    wrote on last edited by
    #1

    Hi there, I am currently using the following code block in my QT application.

    vector<tuple<int, int, char, char>> dirs = {
            make_tuple(0, -1, 'u', 'U'),
            make_tuple(1,  0, 'r', 'R'),
            make_tuple(0,  1, 'd', 'D'),
            make_tuple(-1,  0, 'l', 'L')
        };
    

    However I get an error on the make_tuple() function which says 'Too Many Arguments' as you can see here. I have checked the C++ documentation for the make_tuple() function and it is completely valid to have that many arguments, in fact the error in QT only goes away if I have only 1 variable passed into the make_tuple() function. This code also works in Visual Studio without any problems whatsoever.

    Is this a QT bug?

    kshegunovK 1 Reply Last reply
    0
    • R RBrNx277

      Hi there, I am currently using the following code block in my QT application.

      vector<tuple<int, int, char, char>> dirs = {
              make_tuple(0, -1, 'u', 'U'),
              make_tuple(1,  0, 'r', 'R'),
              make_tuple(0,  1, 'd', 'D'),
              make_tuple(-1,  0, 'l', 'L')
          };
      

      However I get an error on the make_tuple() function which says 'Too Many Arguments' as you can see here. I have checked the C++ documentation for the make_tuple() function and it is completely valid to have that many arguments, in fact the error in QT only goes away if I have only 1 variable passed into the make_tuple() function. This code also works in Visual Studio without any problems whatsoever.

      Is this a QT bug?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @RBrNx277 said:

      Is this a QT bug?

      No it's not, because Qt creator's code parser is not part of Qt. If I may hazard a guess, the code parser couldn't reliably determine that make_tuple is variadic template function or rather it couldn't parse it. The underline you get would be because of that and has no bearing on either compiling or linking, so if your C++ is correct you're fine, no matter what QtCreator thinks.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        There's not a single character of Qt code here so no, it's not a Qt bug. Qt is a library. It has nothing to do with tuples.

        The built-in code model of Qt Creator has not yet caught up with all c++11 features so you will see these sorts of warnings here and there. It's just an IDE highlighter deficiency. Not a bug, just lack of feature :P
        You can safely ignore it. If your compiler supports it the code will compile fine.
        To get better c++11 (and 14) support in the IDE you can switch to the Clang model. It's a little slower but based on a real compiler so will handle these cases better. Go to Tools->Options->C++->Code Model and check "Use Clang Code Model" to enable it.

        1 Reply Last reply
        1
        • R Offline
          R Offline
          RBrNx277
          wrote on last edited by
          #4

          Thank you for your help guys, I hadn't run the code yet because I assumed it would stop during the build, but you were correct and it ran without any problems.

          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