Interior immutability and rvalues
maik klein via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 15 05:51:01 PDT 2016
On Friday, 15 July 2016 at 12:05:47 UTC, ag0aep6g wrote:
> On 07/15/2016 10:29 AM, maik klein wrote:
>> [...]
>
> Sure. Just instantiate Rc with a const/immutable T. I.e., write
> `Rc!(const int)` instead of `const Rc!int`. Or with auto and
> makeRc: `auto rc = makeRc(immutable int(5));`.
>
>> [...]
>
> When you pass an rvalue to a function, the parameter inside the
> function is still an lvalue. The argument being an rvalue just
> means that you can't pass it in a ref parameter.
>
>> [...]
>
> Ok, not being copyable is the problem.
>
>> [...]
>
> If args[0] can be moved, can args[1] and args[2] be moved, too?
> I mean, can you just move everything without testing for
> hasElaborateCopyConstructor? Just a thought.
Thanks I didn't know that you could have type qualifiers inside
templates, D still surprises me sometimes.
I don't think it is practical to call move on "everything", for
example maybe you just want to pass a `ref` or a `class`.
More information about the Digitalmars-d-learn
mailing list