https://d.puremagic.com/issues/show_bug.cgi?id=8845


Maxim Fomin <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]


--- Comment #16 from Maxim Fomin <[email protected]> 2013-11-27 05:09:21 PST 
---
Addressing Manu problem in first post: you cannot do it directly, but can
workaround by 

void foo(T)(ref const T i) {}

ref lvalueOf(T)(T expression)
{
   return [expression][0];
}

struct S(T)
{
   T t;
   ref get() { return t; }
   //alias get this;
}

void main()
{
   //foo(0-0);
   foo((0-0).lvalueOf);
   foo(S!int(0-0).get);
}

Second one is ugly but does not consume heap memory as first one, but it also
requires that foo() does not save reference somewhere (operation is safe
because S!int(0-0) is allocated within main scope, so passing pointer is fine,
until it is saved).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to