Bug 8420 – isExpression and templates should capture all template parameters when using variadic TemplateParameter
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-23T07:12:00Z
Last change time
2012-07-23T10:39:36Z
Assigned to
nobody
Creator
simen.kjaras
Comments
Comment #0 by simen.kjaras — 2012-07-23T07:12:49Z
template TemplateInfo( T ) {
static if ( is( T t == U!V, alias U, V... ) ) {
alias U Template;
alias V Arguments;
}
}
The above template easily matches Tuple!(whatever), since Tuple is a template with only one parameter, which is variadic. It does not, however, match Rebindable!MyClass, since that template does not follow the pattern.
The idea behind bug 3608 was to cover exactly this, but it has been insufficiently communicated in that report, hence this new report.
tl;dr: inside an IsExpression, T... should match a whole TemplateParameterList, not just a TemplateTupleParameter.
Comment #1 by k.hara.pg — 2012-07-23T08:43:53Z
(In reply to comment #0)
> tl;dr: inside an IsExpression, T... should match a whole TemplateParameterList,
> not just a TemplateTupleParameter.
I think, now almost of cases have been covered in 2.060head.
What case isn't covered?
----
template TemplateInfo( T ) {
static if ( is( T t == U!V, alias U, V... ) ) {
alias U Template;
alias V Arguments;
}
}
struct Rebindable(T) {}
struct Tuple(T...) {}
struct Map(alias X, T...) {}
struct Pack(int n, T...) {}
alias TemplateInfo!( Rebindable!int ) T;
pragma(msg, T.Template, " -> ", T.Arguments);
alias TemplateInfo!( Tuple!(int) ) U;
pragma(msg, U.Template, " -> ", U.Arguments);
alias TemplateInfo!( Tuple!(int, int) ) V;
pragma(msg, V.Template, " -> ", V.Arguments);
alias TemplateInfo!( Tuple!(int, 10) ) W;
pragma(msg, W.Template, " -> ", W.Arguments);
alias TemplateInfo!( Map!(Map, int) ) X;
pragma(msg, X.Template, " -> ", X.Arguments);
alias TemplateInfo!( Pack!(10, "str") ) Y;
pragma(msg, Y.Template, " -> ", Y.Arguments);
alias TemplateInfo!( Pack!(10, int) ) Z;
pragma(msg, Z.Template, " -> ", Z.Arguments);
Comment #2 by simen.kjaras — 2012-07-23T10:39:36Z
(In reply to comment #1)
> I think, now almost of cases have been covered in 2.060head.
> What case isn't covered?
No, I think that covers it. Great work!