return type and templates

Ali Çehreli acehreli at yahoo.com
Fri Nov 22 10:17:36 PST 2013


On 11/22/2013 07:14 AM, Jonathan M Davis wrote:

 > I believe that the only cases where the compiler uses the left-hand 
side of of
 > an assignment or initialization to determine anything about the type 
of the
 > right-hand side is when the right-hand side is a literal (be it a lambda
 > literal, array literal, or some other kind of literal).

Any implicit conversion needs that too, e.g. alias this.

struct S
{
     double d;

     alias d this;
}

void main()
{
     auto s = S();
     double d = s;
}

The example will be more impressive when multiple 'alias this' is supported.

Ali



More information about the Digitalmars-d-learn mailing list