[Issue 1012] New: type templates don't support default arguments
Don Clugston
dac at nospam.com.au
Thu Mar 1 07:21:13 PST 2007
d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1012
>
> Summary: type templates don't support default arguments
> Product: D
> Version: 1.007
> Platform: PC
> OS/Version: All
> Status: NEW
> Severity: normal
> Priority: P3
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: thomas-dloop at kuehne.cn
>
>
> # class Bar(T = int){
> # }
> #
> # void foo(T = int)(){
> # }
> #
> # void main(){
> # foo(); // success
> # auto b = new Bar(); // fails
> # }
>
> test.d(9): class test.Bar(T = int) is used as a type
> test.d(9): Error: new can only create structs, dynamic arrays or class objects,
> not void's
>
>
Are you allowed to leave out the !() in class template instantations?
I'd expect to have to write
auto b = new Bar!()();
or at least
auto b = new Bar!();
More information about the Digitalmars-d-bugs
mailing list