C++11 make_tuple() has 'too many arguments' in QT but not Visual Studio
-
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?
-
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?
@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.
-
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.