generic functions

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Apr 28 00:03:56 PDT 2007


Chris Nicholson-Sauls wrote:
> Frits van Bommel wrote:
>> Chris Nicholson-Sauls wrote:
>>> doesn't mind always returning a ulong, I'm sure he could replace all 
>>> those static-if's with one 'static if(is(T:long))'.
>>
>> That should work for all currently implemented types. It'll still 
>> break once cent & ucent are implemented though...
> 
> Ah, oy.  Sometimes I think we should just "implement" cent/ucent as 
> aliases for long/ulong in the meantime.  So many things are going to 
> break when they come to fruition as it is.

That might be a bad idea, since the point of fixed-size integers is that 
they are, you know, fixed-size. :P

However, I'd like it if the following compiled:
---
import std.stdio;
void main() {
     static if(is(cent))
         writefln("cent implemented");
     else
         writefln("no cent yet");
}
---
(and gave the correct output, of course)
Then anybody who cares about this sort of thing would have a way to test 
for it.
And you could use it to define aliases (max_t & umax_t ?) for the 
largest signed and unsigned integers.


More information about the Digitalmars-d-learn mailing list