Default template arguments

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Nov 19 08:35:46 PST 2012


On 11/19/2012 04:47 PM, bearophile wrote:
> Take a look at how Complex does it:
> https://github.com/D-Programming-Language/phobos/blob/master/std/complex.d

Looking, but I don't think that's really what I'm looking for.  AFAICS Complex 
basically operates along these rules:

     -- if your input value(s) are floating point then use the (common) type of
        those values;

     -- if not, then use double

So if e.g. you replace those doubles in the complex() function with reals, then 
calling complex(1.0) will still get you back a Complex!double.

By contrast I'm looking for something like:

     -- if the user doesn't _explicitly specify the type_ then use real,
        regardless of the type of the input.

... or have I missed something?


More information about the Digitalmars-d-learn mailing list