Error with constraints on a templated fuction
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 25 10:10:18 PDT 2014
On Monday, 25 August 2014 at 17:05:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
> On Mon, Aug 25, 2014 at 03:48:10PM +0000, Jeremy DeHaan via
> Digitalmars-d-learn wrote:
>> I've done things like this before with traits and I figured
>> that this way
>> should work as well, but it gives me errors instead. Perhaps
>> someone can
>> point out my flaws.
>>
>> immutable(T)[] toString(T)(const(T)* str)
>> if(typeof(T) is dchar)//this is where the error is
>
> The correct syntax is:
>
> if (is(typeof(T) == dchar))
Almost... T is already a type; typeof(T) doesn't compile.
More information about the Digitalmars-d-learn
mailing list