jeudi 22 septembre 2016

gcc compiler error declaring std::list of shared pointers to abstract class

I have an abstract base class that looks like this (header only, no cpp file):

#ifndef AI_DEVICE
#define AI_DEVICE

#include <stdio.h>
//several more header files included here

using namespace std;
using namespace ci;
using namespace ci::app;

namespace ai
{
    using namespace collision;

    namespace adapter
    {
        class Device {

            public:

                virtual ~Device()=0;

                //get / set
                virtual int PixelCount()=0;

                virtual void SetPixelCount( const int pixelCount )=0;

                //there are several more virtual methods defined here
        };
    }
}

#endif //AI_DEVICE

In another header that includes Device.h I'm trying to forward declare a list of shared pointers to Device like this:

list<shared_ptr<Device>> _devices;

Additionally, I have several methods in other classes whose headers include Device.h that take a list of shared pointers to Devices as an argument like this:

void DrawToFbo( const int currentDevice, std::list<shared_ptr<Device>> & deviceList, gl::FboRef pickingFbo );

For each case mentioned above, I'm getting an error from my gcc compiler (using CLion/CMake on Ubuntu 16.04) regarding the use of Device as a template argument. That error looks like this:

error: template argument 1 is invalid

Per the design of the project I'm working on, the Device class should be abstract. There are several specific device classes that will inherit from it. The goal is to be able to keep multiple instances of the base class that are instantiations of the derived classes in the same container. That said, I did try making all methods of the Derived class non-virtual and still saw the same compiler error.

I've also combed through the code carefully looking for obscure errors, circular dependencies, etc. Can anyone see something here that I'm not seeing?

Aucun commentaire:

Enregistrer un commentaire