www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16707] New: [Templates] run variadic templates example failed


          Issue ID: 16707
           Summary: [Templates] run variadic templates example failed
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: panmengh gmail.com

Hi, I am very new to dlang, the following example can't be compiled, my dmd
version is "DMD32 D Compiler v2.072.0".


template print(args...)
    void print()
        writeln("args are ", args); // args is a ValueSeq

template write(Args...)
    void write(Args args) // Args is a TypeSeq
                          // args is a ValueSeq
        writeln("args are ", args);

void main()
    print!(1,'a',6.8).print();                    // prints: args are 1a6.8
    write!(int, char, double).write(1, 'a', 6.8); // prints: args are 1a6.8

app.d(31): Error: template app.print cannot deduce function from argument types
!()(void), candidates are:
app.d(11):        app.print(args...)()
app.d(32): Error: function app.write!(int, char, double).write (int _param_0,
char _param_1, double _param_2) isnot callable using argument types ()

Nov 21 2016