Should I use QScopedPointer or std::unique_ptr?

后端 未结 3 2242
后悔当初
后悔当初 2021-02-19 10:59

I\'m starting a new project, using Qt5 and QMAKE_CXXFLAGS += -std=c++1y. I\'m not sure whether I should prefer QScopedPointer or std::unique_ptr

3条回答
  •  醉话见心
    2021-02-19 11:12

    Even though the main intention of both classes is similar,one important difference between those two which makes you to take some business decision.

    QScopedPointer does not have an assignment operator. Where as std::unique_ptr has assignment operator.

    If you want to be strict on your QT object/control and does not want an assignment use QScopedPointer.

提交回复
热议问题