Thread overview
[Issue 8420] New: isExpression and templates should capture all template parameters when using variadic TemplateParameter
Jul 23, 2012
Simen Kjaeraas
Jul 23, 2012
Kenji Hara
Jul 23, 2012
Simen Kjaeraas
July 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8420

           Summary: isExpression and templates should capture all template
                    parameters when using variadic TemplateParameter
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: simen.kjaras@gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2012-07-23 07:12:49 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8420



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-23 08:43:53 PDT ---
(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);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8420


Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> 2012-07-23 10:39:36 PDT ---
(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!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------