Move Constructors - Converting Lvalues to Rvalues
Timon Gehr
timon.gehr at gmx.ch
Thu Oct 3 00:04:03 UTC 2024
On 10/3/24 01:07, Manu wrote:
> On Thu, 3 Oct 2024 at 03:21, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com <mailto:digitalmars-d at puremagic.com>> wrote:
>
> On 10/1/2024 1:15 PM, Timon Gehr wrote:
> > I guess the new implementation you have in mind is something like
> the following?
> >
> > ```d
> > auto move(T)(ref T arg)=>__rvalue(arg);
> > ```
>
> Not exactly. __rvalue would also convert an rvalue to an rvalue.
>
>
> -preview=rvaluerefparams addresses this; it allows an rvalue to be
> supplied to the lvalue there. It's actually an essential mechanic to
> this whole thing, because it will allow the appropriate selection of
> copy/move overloads where a type may define either one, or both. If a
> copy and/or move constructor exists, it needs to select the proper one,
> and the -preview handles that properly as is.
`-preview=rvaluerefparam` allows you to treat an rvalue as an lvalue
implicitly in some contexts.
`__rvalue` allows you to treat an lvalue explicitly as an rvalue, so it
will be moved.
I fail to see how those are related.
More information about the Digitalmars-d
mailing list