static if (is (T==Complex))

Norm norm.rowtree at gmail.com
Wed Sep 18 11:25:21 UTC 2019


On Wednesday, 18 September 2019 at 11:10:11 UTC, berni wrote:
> Is it possible to simplfy this?
>
>>static if (is (T==Complex!double) || is (T==Complex!float) || 
>>is (T==Complex!real))

I usually do something like the following:
---
import std.traits;


template isComplexReal(T) {

   enum isComplexReal = is(T == Complex!R, R) && 
(isFloatingPoint!R);
}


static if(isComplexReal!T) {// do something}
---


More information about the Digitalmars-d-learn mailing list