I often use a pattern of having const ref struct parameters (as
in C++) but this doesn't work in the case of rvalues. The
workaround of defining an overload that calls its own name is
terrible. I understand there was a DIP 1016 by Manu asking for
this case to work. As far as I can tell, this was rejected, but
later reconsidered, and now Andrei is starting up a new one?
Apologies but I'm not sure where these discussions are
centralized. But if anyone has any idea or guess how seriously
and in what kind of time this could be expected, that would be my
first side question.
My main learning question is whether the const ref parameter
pattern is good in D? In C++ I see it everywhere, but are there
better alternatives, in particular in D, or is there no point
because some copy elision optimization may be guaranteed? In
short am I right in writing const ref parameters, or am I doing
something silly (and as important as this DIP may otherwise be,
it wouldn't affect me as much as I think)??
As far as I can see, this DIP would be helpful for two use cases:
const ref, and return ref with method chains. Are there others?
- DIP 1016 and const ref parameters XavierAP via Digitalmars-d-learn