A quick example:
class GraphicObject : public sf::Drawable, public sf::Transformable
{
public:
template <class D> // D can be sf::Sprite, for instance
explicit GraphicObject(D* derivate)
: sf::Drawable()
, sf::Transformable(*derivate)
, mDrawable(derivate)
{
// Reset transforms of original SFML object
derivate->SetPosition(0.f, 0.f);
derivate->SetRotation(0.f);
derivate->SetScale(1.f, 1.f);
derivate->SetOrigin(0.f, 0.f);
}
void Draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.Transform *= GetTransform();
target.Draw(*mDrawable, states);
}
private:
std::unique_ptr<sf::Drawable> mDrawable;
};
A side note: In case you need value semantics, you can use thor::CopiedPtr instead of std::unique_ptr. This smart pointer copies the object every time it is itself copied, even through polymorphic hierarchies. It is however not as flexible as it could be, I will improve (not to say reimplement) it in the future.