Forward declaration of QExplicitlySharedDataPointer<T>



  • Hi,

    I have started converting many of the C++ classes in my application to QExplicitlySharedDataPointer<T> in order to avoid using raw pointers which became unmanageable as the application grew in size. My implementation is based on Qt's documentation http://doc.qt.io/qt-5/qshareddatapointer.html. Hence split up each class into 2 classes: a data class which holds the member variables and another class that holds the QExplicitlySharedDataPointer and the member methods.

    Using raw pointers it was possible to use forward declarations in the header files which had some significant advantages over includes:

    • Avoid circular include dependencies
    • Do not recompile everything when a header file is modified

    Unfortunately I don't know how to forward declare a class that uses QExplicitlySharedDataPointer<T>, so I am using includes for now which deteriorates compile time and brings back the issue of circular include dependencies.

    So my question is whether it is possible to forward declare a class that uses QExplicitlySharedDataPointer<T> and how?


  • Moderators

    @linolium said in Forward declaration of QExplicitlySharedDataPointer<T>:

    So my question is whether it is possible to forward declare a class that uses QExplicitlySharedDataPointer<T> and how?

    Forward declaration of templated classes:

    template <class T>
    QExplicitlySharedDataPointer;
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.