You probably want MultiMethods. Specifically, you want runtime-dispatch on actual type.
Here's a post about them: "type-switch" construct in C++11
BTW: As you are always using std::shared_ptr
with all objects derived from Shape
, consider using std::enable_shared_from_this
.
Also, you might want to create a bounding box and check for empty intersection. As an added optimisation, add an empty shape (static Singleton object). Shape
itself is a good type for it.