C++ generic double-dispatcher/visitor
I have implemented something like that in one of my projects, the trick is to use CRTP to pass the Child type to the parent.

This is a simplified code :

#include "collisions.h"
#define SHAPES Box, Sphere, Mesh
class Box;
class Sphere;
class Mesh;

class Geometry;

// Collidable defines all the pure virtual functions.
template &lt;typename... Shapes&gt;
struct Collidable;

template &lt;&gt;
struct Collidable&lt;&gt; {
    virtual bool collide(const Geometry* obj) const = 0 ;
};

template &lt;typename Shape, typename... Others&gt;
struct Collidable&lt;Shape, Others...&gt; : Collidable&lt;Others...&gt; {
    using Collidable&lt;Others...&gt;::collide;
    virtual bool collide(const Shape* obj) const = 0;
};

// Geometry inherits from Collidable and is our common base class.
class Geometry : public Collidable&lt;SHAPES&gt; {
    public:
        Geometry();
        virtual ~Geometry();
        glm::vec3 getPosition() const;

    private:
        glm::vec3 m_pos;
};

// Dispatcher inherits from Geometry and implements one dispatch function
// for all the given type and the Geometry one.
template &lt;class T, typename... Shapes&gt;
struct Dispatcher;

template &lt;class T&gt;
struct Dispatcher&lt;T&gt; : public Geometry {
    bool collide(const Geometry* obj) const final override {
        return obj-&gt;collide(static_cast&lt;const T*&gt;(this));
    }
};

template &lt;class T, typename Shape, typename... Others&gt;
struct Dispatcher&lt;T, Shape, Others...&gt; : public Dispatcher&lt;T, Others...&gt; {
    using Dispatcher&lt;T, Others...&gt;::collide;
    bool collide(const Shape* obj) const final override {
        return Collisions::collide(obj, static_cast&lt;const T*&gt;(this));
    }
};

// Shape&lt;T&gt; is our generic dispatch class.
template &lt;class T&gt;
class Shape : public Dispatcher&lt;T, SHAPES&gt; {};


With all shapes defined like:

class Sphere : public Shape&lt;Sphere&gt; {...};

Of course, all the corresponding Collisions::collide(*,*) must be declared.
I am not very familiar with template meta-programming, so I couldn't find a clean solution to replace the #define SHAPES Box, Sphere, Mesh and the classes declarations at the beginning of the file.

Furthermore, I don't know if a good compiler can optimize virtual calls using de-virtualization (that's why I tried to add final keyword).