digitalmars.D.learn - RefRange behavior
Hi all, given this: ´´´ import std.range; size_t[] arr; struct S { RefRange!(size_t[]) member; } void fun(ref size_t numByRef){} void main() { arr.length = 42; S s; s.member = refRange(&arr); static assert(__traits(compiles, fun(s.member[0]))); static assert(!__traits(compiles, fun(s.member.front))); //fun(s.member.front); /* source/app.d(19,5): Error: function `app.fun(ref ulong numByRef)` is not callable using argument types `(ulong)` source/app.d(19,5): cannot pass rvalue argument `s.member.front()` of type `ulong` to parameter `ref ulong numByRef` */ } ´´´ Why does the last static assert yields false? Is there a simple workaround, maybe?
Mar 14 2018
On Wednesday, 14 March 2018 at 10:22:45 UTC, Alex wrote:Is there a simple workaround, maybe?ok, the workaround would be to enumerate the member and to use the former notation.
Mar 14 2018