I&#x27;m not a C++ expert but can you solve this using something more like the functional approach in C++, by defining a templated function and then specializing it in the extension modules for the various classes? (I guess the specialized declarations would need to be #included somehow, but that&#x27;s not too big of a hurdle.)