pkj
29th April 2013, 20:12
QSharedPointer gives nasty compile time warnings if the class whose smart pointer is being made is forward declared. QScopedPointer documentation has some documentation on how to avoid warnings with forward declaration. As has been pointed out in this bug, works for QSharedPointer too...
https://bugreports.qt-project.org/browse/QTBUG-7302
However compiler warnings persist for me... consider code...
class MyPrivateClass; // forward declare MyPrivateClass
class MyClass
{
private:
QList<QScopedPointer<MyPrivateClass> > privatePtr; //QList QScopedPointer to forward declared class
public:
MyClass(); // OK
~MyClass(); // Not a VIOLATION - Destructor must not be inline
private:
Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
// are now disabled, so the compiler won't implicitely
// generate them.
};
Any way to avoid the warnings.. the qt version is 4.8.4... the bug is apparently fixed in 5.0 but can't shift.
https://bugreports.qt-project.org/browse/QTBUG-7302
However compiler warnings persist for me... consider code...
class MyPrivateClass; // forward declare MyPrivateClass
class MyClass
{
private:
QList<QScopedPointer<MyPrivateClass> > privatePtr; //QList QScopedPointer to forward declared class
public:
MyClass(); // OK
~MyClass(); // Not a VIOLATION - Destructor must not be inline
private:
Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
// are now disabled, so the compiler won't implicitely
// generate them.
};
Any way to avoid the warnings.. the qt version is 4.8.4... the bug is apparently fixed in 5.0 but can't shift.