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

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Dec 13 13:02:50 UTC 2021


On Monday, 13 December 2021 at 12:51:17 UTC, evilrat wrote:
> That example is still looks very conspicuous because it is very 
> likely does nothing on the caller side in C++ as it passes a 
> copy.

Yes, I wouldn't want to use it, maybe manual mangling is better, 
but still painful. ```const A&``` is so common in C++ API's that 
it really should be supported out-of-the-box.  All it takes is 
adding a deref-type-constructor to the D language spec, e.g. 
```ref const(@deref(A))```



More information about the Digitalmars-d-learn mailing list