[SOLVED] make_unique Too Few Arguments in Creator

Issue

#include <QCoreApplication>
#include <iostream>
#include <memory>

using namespace std;

class A{
public:
    A(){cout << "ctorA " << endl;}
    ~A(){cout << "dtorA " << endl;}
};

class X{
    A arr[10];
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    { unique_ptr<X> upX = make_unique<X>(); }

    return a.exec();
}

Qt Creator underlines std::make_unique and when I hover over it with mouse, it tells me there are “Too few arguments”. Compiles and runs fine. No errors or warnings as far as I can tell. Am I doing something wrong or is this a bug in Creator or something? Newest compiler gcc7.3.something and Qt10.something. Just got it today.

Solution

Qt Creator seems to have issues with c++14 syntax highlighting, as pointed out in many threads in Qt forums (e.g. here and here).

The suggested solution is to enable the Clang Code Model plugin
which seems to solve the issue, although I noticed some problems with automatic code formatting (Ctrl-I) when using the single quotation mark as a digit separator. Also #ifdef‘s are having this kind of issue (solved closing/reopening the file). I’m using Qt Creator 4.4.1 on Ubuntu.

Answered By – p-a-o-l-o

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *