Re: Template function type inference with default arguments

2015-01-05 Thread anonymous via Digitalmars-d-learn
On Sunday, 4 January 2015 at 00:22:01 UTC, ixid wrote: Why don't templates take a type from the default argument if nothing else is supplied? https://issues.dlang.org/show_bug.cgi?id=2803

Template function type inference with default arguments

2015-01-03 Thread ixid via Digitalmars-d-learn
Why don't templates take a type from the default argument if nothing else is supplied? It would be useful to be able to use an enum to set a default. enum MAX = 1_000; auto sieve(T)(T max = MAX) { import std.bitmanip : BitArray; BitArray n; n.length = max; T[]

Re: Template function type inference with default arguments

2015-01-03 Thread Meta via Digitalmars-d-learn
On Sunday, 4 January 2015 at 00:22:01 UTC, ixid wrote: Why don't templates take a type from the default argument if nothing else is supplied? It would be useful to be able to use an enum to set a default. I doubt anyone's ever thought of that particular use-case. Using your typeof(MAX)