sf::Drawable is a virtual "base" type. To be an 'actual' type, it requires to be derived/inherited. For example, any of the pre-defined shapes such as sf::RectangleShape, sf::CircleShape and sf::Sprite etc..
You can, however, hold pointers to that base type in an attempt to hold different children types.
Be careful though because it requires casting to and from the different types when needed. This means that something, somewhere, needs to know what type this is, if you need any of the children's features. You can, of course, use the base stuff such as draw easily.
Note that an std::vector is not an array (or std::array). Where arrays take [] to determine its size, a vector does not. It takes a parameter instead (so () or {}) but it can also be created empty and elements/items can added individually later.
If you are wanting an array of vectors (or a vector or arrays), it would be better to specify it like this:
std::array<std::vector<const sf::Drawable*>, 5u> layers{}; // an array of size 5, each with a vector of drawable pointers.
e.g.
std::vector<const sf::Drawable*> buffer(5u); // or std::array<sf::Drawable*> buffer[5u];
void WindowHandler::draw(const sf::Drawable& targ, int priority)
{
buffer[priority] = dynamic_cast<const sf::Drawable*>(&targ);
}
void WindowHandler::render()
{
win.clear();
for(int i = 4; i >= 0; i--)
{
for(const auto& t : buffer[i])
{
if (t != nullptr)
win.draw(*t); // i expect this to work...
}
buffer[i].clear();
}
win.display();
}
I haven't tested this exact code; a lot of it is copied directly from your post.
Another way to approach this, is to create a structure that holds priority and the drawable's pointer and then have a vector of those. Then, you can sort them easily using that priority.
e.g.
struct OneThing
{
int priority
sf::Drawable* drawable;
}
std::vector<OneThing> things{};
std::sort(things.begin(), things.end(), [](OneThing lhs, OneThing rhs){ return lhs.priority > rhs.priority; });
EDIT:
modified the cast from "reinterpret_cast" to "dynamic_cast".