digitalmars.D.learn - Cannot pass const(T) to function with ref const(T)
- Andrey (5/8) Mar 13 2021 where Data and Word - structs.
- Andrey (2/6) Mar 13 2021
- Steven Schveighoffer (5/11) Mar 13 2021 Yeah, D does not allow (without a switch) passing an rvalue (i.e. a
Hello, Dmd gives an error:Error: function `_setPastBases(ref const(Data) item, ref const(Word!(wstring, wstring)) base)` is not callable using argument types `(const(Data), Word!(wstring, wstring))where Data and Word - structs. What happens and how to pass arguments? Ldc compiles without such error.
Mar 13 2021
Mistake. It says about simple argument:cannot pass rvalue argument `xxxxx` of type `Word!(wstring, wstring)` to parameter `ref const(Word!(wstring, wstring)) base`Function:void _setPastBases(const ref Data item, const ref UsualWord base)
Mar 13 2021
On 3/13/21 5:24 PM, Andrey wrote:Mistake. It says about simple argument:Yeah, D does not allow (without a switch) passing an rvalue (i.e. a temporary) into a reference. There is a preview switch for it, I think -preview=rvaluerefparam -Stevecannot pass rvalue argument `xxxxx` of type `Word!(wstring, wstring)` to parameter `ref const(Word!(wstring, wstring)) base`Function:void _setPastBases(const ref Data item, const ref UsualWord base)
Mar 13 2021