How to pass a class by (const) reference to C++

evilrat evilrat666 at
Tue Dec 14 07:50:48 UTC 2021

On Tuesday, 14 December 2021 at 06:21:39 UTC, Tejas wrote:
> Hey, evilrat, I've seen people make claims that our C++ interop 
> has reached phenomenal levels and that going any further would 
> basically require a C++ compiler ala ImportC++, the issue is 
> just that the docs haven't been updated yet to reflect it.
> What do you think about this? Is this really true? Because it 
> sure doesn't look that way to me :(

Unfortunately it is mostly true.
There is some missing features like above tail ref and const, 
there is minor mangling issues that requires pragma mangle 
sometimes, and other annoying little details.

Aside from that there is things that requires actual C++ compiler 
OR at least part of it to enable certain C++ features - like the 
example above with pass-by-value for classes certainly requires 
real C++ copy constructor, some operator overloads, use of SFINAE 
instead of CTFE, and I'm sure there is more of such nuances.

All this not going to happen, D spec clearly states it allows 
limited C++ interop by relying on linker mechanics rather than 
being C++ compatible language.

It is now abandoned but there was LDC fork called "Calypso", it 
was a mixed clang/LDC compiler that aimed to achieve seamless 
D/C++ interop and from what I've heard it was working just fine 
without all this hiccups as above.

More information about the Digitalmars-d-learn mailing list