Templates - Numeric Types only

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Aug 6 18:19:07 PDT 2009


Kevin wrote:
> Hi,
> simple Question:
> Is it possible to allow just numeric types in templates?
> For example to create a Vector Class like this:
> 
> class Vector(T:"numeric" = float, int size = 4)
> 
> Thanks,
> Kevin

import std.traits;

class Vector(T, int size = 4) if (isNumeric!T)
{
     ...
}


Andrei



More information about the Digitalmars-d mailing list