> Let's say version 1.5.6 of my shared library (a DLL file on MS-Windows, or an SO file on Linux), contains the following class:

> […]

 

I think I understand the problem and what you are trying to do.

This is very specific behavior related to how .dll linking works, and correct me if I’m wrong, but as far as the C++ standard goes it doesn’t know what a dll is.

What you are trying to do works for reasons that got nothing to do with C++, it’s all UB that just happens to work in practice.

C++ won’t be able to help you because it is technically an ODR violation.