http://d.puremagic.com/issues/show_bug.cgi?id=10945
Summary: Type extracted in an 'is' expression in a constraint
should be visible in the template body
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: druntime
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Andrej Mitrovic <[email protected]> 2013-09-01
16:50:44 PDT ---
Here's some interesting code another user has provided, with a reduced
test-case:
-----
struct Templ(Args...)
{
}
struct WillWork(alias T)
if (is(T : Templ!Args, Args...))
{
static if (is(T : Templ!Args, Args...))
alias A = Args[0];
else
static assert(0);
}
struct WontWork(alias T)
if (is(T : Templ!Args, Args...))
{
// Error: undefined identifier Args, did you mean alias T?
alias A = Args[0];
}
void main()
{
alias C = Templ!int;
alias B = WillWork!C;
B.A a;
alias B2 = WontWork!C; // ng
}
-----
Note how the 'WillWork' template has to redundantly duplicate the constraint
into a static if condition. It would be simpler if the body of the template had
access to the types which were extracted with the 'is' expression in the
template constraint.
I can't think of any harm this would do, it would be beneficial. If the
template is extracting the types like that, it probably wants something to do
with those types in the template body.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------