D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16707 - [Templates] run variadic templates example failed
Summary: [Templates] run variadic templates example failed
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL: http://dlang.org/
Keywords: pull, trivial
Depends on:
Blocks:
 
Reported: 2016-11-21 09:52 UTC by panmengh
Modified: 2023-02-02 12:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description panmengh 2016-11-21 09:52:52 UTC
Hi, I am very new to dlang, the following example can't be compiled, my dmd version is "DMD32 D Compiler v2.072.0".

https://dlang.org/spec/template.html#variadic-templates

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 ()
Comment 1 berni44 2019-12-24 12:42:37 UTC
Should be

void main()
{
    print!(1,'a',6.8)();                    // prints: args are 1a6.8
    write!(int, char, double)(1, 'a', 6.8); // prints: args are 1a6.8
}
Comment 2 Dlang Bot 2023-02-02 11:05:09 UTC
@AndreeaDrehuta created dlang/dlang.org pull request #3516 "Fix issue 16707" fixing this issue:

- Fix issue 16707

https://github.com/dlang/dlang.org/pull/3516
Comment 3 Dlang Bot 2023-02-02 12:15:22 UTC
dlang/dlang.org pull request #3516 "Fix issue 16707" was merged into master:

- 8f33642546b9163478e56d5f6a49ef8fbaae6015 by Drehuta Andreea:
  Fix issue 16707

https://github.com/dlang/dlang.org/pull/3516