Container::Pointer does not work with forward declaration anymore
linuxaged opened this issue · 3 comments
class BonvRenderer;
class Scene {
Corrade::Containers::Pointer<BonvRenderer> _bonvRenderer;
}
Error: static assertion failed due to requirement 'Implementation::IsCompletebon::BonvRenderer::value': attempting to delete a pointer to an incomplete type corrade\src\Corrade\Containers\Pointer.h 299
The implicit Scene destructor is defined inline by the compiler, at which point BonvRender is not yet defined. You need an explicit destructor (can be defaulted) at the point where BonvRender is defined.
// Scene.h
class BonvRenderer;
class Scene {
public:
~Scene();
private:
Corrade::Containers::Pointer<BonvRenderer> _bonvRenderer;
}
// Scene.cpp
#include "BonvRender.h"
Scene::~Scene() = default;
Yes, as @pezcode says. You have to define a (defaulted) destructor in the cpp file, and potentially also a (defaulted) copy/move constructor and assignment.
Before it worked only seemingly, in particular it may not have correctly called BonvRenderer
destructor, only freeing the memory, potentially causing leaks of nested resources. On some compilers such usage may have produced a warning, on some not. Now it's made into a hard error to prevent such accidents.
thanks, just known it's explained in corrade doc