Casting lvalues

z z at z.com
Fri Apr 2 12:47:35 UTC 2021


```d
shared TT[] a;
T processArray(T)(ref T[] p){/*...*/} //function calls .reserve 
on its parameter
a.processArray;
```
>Template *name* cannot deduce function from argument types 
>!()(shared(T[]))...

Even if the function is changed to only accept shared parameters, 
.reserve does not appear to support shared so the function is 
impossible to use without somehow changing its type or using 
__gshared.
Other than using pointers and 
casting(```processArray(*(cast(Unqual!TT*)&a))```, not ideal), is 
there a better way to transform an lvalue's type without it 
transforming into an rvalue?(direct casting seems to create an 
rvalue because compilation fails.)
Thanks


More information about the Digitalmars-d-learn mailing list