return type and templates
Jonathan M Davis
jmdavisProg at gmx.com
Fri Nov 22 07:14:12 PST 2013
On Friday, November 22, 2013 15:20:30 Timon Gehr wrote:
> On 11/22/2013 02:50 PM, Dicebot wrote:
> > On Friday, 22 November 2013 at 13:43:49 UTC, Andrea Fontana wrote:
> >> I assumed that it knows - when is trying to instatiate s.value
> >> template - that "s.value" is part of an assignment and that it will be
> >> assigned to an int.
> >
> > This is somewhat wrong part. "s.value" is distinct separate expression
> > that must be evaluated by compiler on its own before proceeding. The
> > fact that it is later used in assignment expression is not know at that
> > moment.
>
> Lambda parameter type deduction needs to know this too.
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).
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list