Return type deduction
Andrea Fontana via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 8 07:54:17 PDT 2016
On Thursday, 8 September 2016 at 13:28:15 UTC, Steven
Schveighoffer wrote:
> Right, but there is a problem here. The connection of the
> simple return type to the simple template parameter is not
> necessarily guaranteed. That is, there is no guarantee
> simple!int is going to return int (for any template).
>
> This means the compiler has to determine how to make simple
> return an int, and this isn't always obvious, or easy to
> determine.
I don't know how compiler works, but my logic was:
- I have T simple(T) { ... }
- return type == template argument
- int ... = simple() => T == int => simple!int
I undestand that if it was:
auto simple(T) { ... } it should be difficult
Probably I'm missing someting about compiler internal structure,
not my field.
Andrea
More information about the Digitalmars-d
mailing list