On Tuesday, February 20, 2024, Andrey Erokhin wrote:

I think impossible b/c of name mangling


Name mangling hadn't crossed my mind. I would be fine for 'extern C' functions though.

Note here though that this is impossible because of something not acknowledged by the Standard -- name mangling.

However, if I knew that the mangled name was something like "9InterfaceIXadL_Z3fooIiEiRT_EEE", then I could potentially ask the compiler to accept a mangled name as a forward declaration, perhaps something like:

    class IDevice -> InterfaceIXadL_Z3fooIiEiRT_EEE;

And so then if the compiler finds a definition of 'IDevice' further along in the translation unit, for example:

    typedef Interface<true> IDevice;

then it can issue a diagnostic if the two mangled names don't match.