While the previous gist documented my attempt at finding a working solution, this one provides a small working example.
Here, the library code declares classes A and B both inheriting form a base class Base. A Visitor is introduced, and both A and B have a apply method that calls the appropriate visitor method.
The client introduces a new class C that also inherits from base, and
which is able to use a Visitor-derived class on any Base*
pointer,
be it a A, a B or a C under the hood.