[Issue 7529] IFTI does not support template argument dependent template alias instances as parameter types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 17 08:00:11 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7529
--- Comment #14 from Kenji Hara <k.hara.pg at gmail.com> 2012-02-17 07:59:59 PST ---
(In reply to comment #12)
> An alias template is like a function template, just for aliases.
>
> Those are all alias templates:
>
> template A(T){alias T A;}
> template B(T){alias Foo!T B;}
> template C(T){alias foo.bar.Qux!T C;}
> template D(T){alias Foo!(Bar!(Qux!T)) D;}
>
> Those are functions that use them:
> void fooa(T)(A!T a){ ... }
> void foob(T)(B!T b){ ... }
> void fooc(T)(C!T c){ ... }
> void food(T)(D!T d){ ... }
>
> Those are the versions that do exactly the same thing but work with IFTI:
> void fooa(T)(T a){ ... }
> void foob(T)(Foo!T b){ ... }
> void fooc(T)(foo.bar.Qux!T c){ ... }
> void food(T)(Foo!(Bar!(Qux!T)) d){ ... }
>
> What I am asking for is for IFTI to work the same for the former and latter
> versions of the functions. This is easy to implement and matches what most
> programmers would expect the language to be capable of.
OK, I almost understand what you expects.
When the two declarations exist,
> template B(T){alias Foo!T B;}
> void foob(T)(B!T b){ ... }
and calling foob with IFTI like follows:
Foo!int x;
foob(x); // foob(T)(B!T) is converted to foob(T)(Foo!T)
// *with expanding template B*, then foob deduces T as int.
OK?
-----
There is some problems about this enhancement.
1) This enhancement requires adding a phase to expanding eponymous templates
used as function parameter type. This makes IFTI process more complicate.
2) Some eponymous templates are not one liner.
template X(T) {
template Y(U) { ... } // massive type calculation
alias Y!T X; // also eponymous template
}
void foo(T)(X!T) { ... }
Should compiler calculate T from X!T? It is almost impossible!
If it only works with one-linear eponymous template, it is less benefit than
the semantic complexity.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list