On Monday, 13 December 2021 at 15:21:19 UTC, Jan wrote:
On Monday, 13 December 2021 at 13:02:50 UTC, Ola Fosheim
Grøstad wrote:
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))```
I fully agree. This pattern is so common in C++, that I am
surprised D doesn't have a way to do this already. The whole
idea of linking against C++ is to interop easily, with little
friction and high performance. Needing to build any shims or
redesign the C++ side is very much contrary to this goal.
Does anyone know whether such issues have been discussed
before? I can't imagine I'm the first one to run into this.
A similar issue about tail const classes has already been
discussed:
https://digitalmars.com/d/archives/digitalmars/D/const_Class_is_mangled_as_Class_const_const_299139.html
I made a pull request, which changes the mangling to tail const
for classes passed directly as parameter or return type, but now
think this would break too much code:
https://github.com/dlang/dmd/pull/13369
The proposal to add a deref-type-constructor, would also allow to
have tail const classes.