July 14

On Wednesday, 14 July 2021 at 08:24:03 UTC, Tejas wrote:

>

Last question:

How do you exactly specify that you're expecting a rvalue reference as a parameter?
In other words, what is the D equivalent of this C++ code:

func(T&& parameter) { }

There isn't. in is for const references. -preview=rvaluerefparam will allow you to get a mutable ref, but it simply creates a temporary at the call site (so does -preview=in). To my knowledge, we can't represent that in D (and we can't bind to such a definition in C++).

July 14

On Wednesday, 14 July 2021 at 14:51:41 UTC, Mathias LANG wrote:

>

On Wednesday, 14 July 2021 at 08:24:03 UTC, Tejas wrote:

>

Last question:

How do you exactly specify that you're expecting a rvalue reference as a parameter?
In other words, what is the D equivalent of this C++ code:

func(T&& parameter) { }

There isn't. in is for const references. -preview=rvaluerefparam will allow you to get a mutable ref, but it simply creates a temporary at the call site (so does -preview=in). To my knowledge, we can't represent that in D (and we can't bind to such a definition in C++).

Well... that's not good.

Hope DIP 1040 gets here soon then, since rvalue references seem to be explicitly mentioned as getting added, or are there caveats in that DIP as well?

Next ›   Last »
1 2