Bug 16707 – [Templates] run variadic templates example failed

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-11-21T09:52:52Z
Last change time
2023-02-02T12:15:22Z
Keywords
pull, trivial
Assigned to
No Owner
Creator
panmengh

Comments

Comment #0 by panmengh — 2016-11-21T09:52:52Z
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 by bugzilla — 2019-12-24T12:42:37Z
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 by dlang-bot — 2023-02-02T11:05:09Z
@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 by dlang-bot — 2023-02-02T12:15:22Z
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