I'm trying to implement a quadtree, and I want to put it in a library so that I don't have to copy and refactor the code every time I need it. What I've came up with are a hasPos
and a hasDim
interfaces so that I have rectangle-like objects to work with:
class hasPos {
protected:
vec2 pos;
};
class hasDim: public hasPos {
protected:
vec2 dim;
// ...
};
template<int capacity, typename t, typename = std::enable_if<std::is_base_of<hasDim, t>::value && std::is_pointer<t>::value>>
class quadtree {
quadtree<capacity, t> nw, ne, sw, se; // for subdivision when capacity is exceeded
// ...
};
When I compile the library it works just fine, but when I compile a project with a quadtree
in it, the compiler complains about an incomplete type:
error: 'quadtree<capacity, t, <template-parameter-1-3> >::ne' has incomplete type
It really looks as if std::enable_if
is the problem.
EDIT :
As suggested in the comments, I turned nw, ne, sw, se
into *nw, *ne, *sw, *se
. It seemed to work, but a few hours later it's again complaining about an incomplete type, after I moved the implementation into a compilation unit:
bin.cpp:32:40: error: invalid use of incomplete type 'struct quadtree<capacity, t>'
32 | void quadtree<capacity, t>::addObj(t o) {
|