std.traits and std.string incompatible ?

Ali Çehreli acehreli at yahoo.com
Tue Mar 8 09:34:19 PST 2011


On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:
 > Hi,
 >
 > When running the following file:
 >
 > #!../dmd2/linux/bin/rdmd -unittest
 > import std.string, std.traits;
 > void main(string[] args){
 > 	bool test = isNumeric(args[0]);
 > }
 >
 > I get the error :
 > dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template
 > std.traits.isNumeric(T) is not a function template
 >
 > Is this a bug or is there something deprecated ?
 >
 > Wilfried


isNumeric is a template. You are supposed to give it a type:

   if (isNumeric!SomeType)

or at compile time:

   static if (isNumeric!SomeType)

It doesn't work with string values. Although unnecessary, you could do this:

     bool test = isNumeric!(typeof(args[0]));

Ali


More information about the Digitalmars-d-learn mailing list