Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED]How do I make unique pointers work?



  • In my code, I want to use unique pointers. However, I get this error message:

    'unique_ptr' in namespace 'std' does not name a type

    In the code, I have this globally:

    std::unique_ptr<Tools> Engine(new Tools);

    Apparently I have to use C++11, but I already have CONFIG += c++11 in the .pro file.

    So what gives? Does it matter where I put the CONFIG-text in the .pro file?



  • What errors are you getting? Did you #include<memory> where you're trying to use unique_ptr? You might need to add the following to your .pro (in addition to the CONFIG setting):

    @QMAKE_CXXFLAGS += -std=c++11@



  • Ah, I didn't, I completely forgot about that. Thanks for pointing that out!



  • No problem. If it works, please mark the thread as SOLVED :)


Log in to reply