## digitalmars.D.learn - static if (is (T==Complex))

• berni (1/3) Sep 18 2019
• Norm (10/13) Sep 18 2019 I usually do something like the following:
• berni (2/3) Sep 18 2019 Ah great. I was looking for "is(T == Complex!R, R)". :-) Thanks!
• Steven Schveighoffer (5/9) Sep 18 2019 https://dlang.org/phobos/std_traits.html#TemplateOf
```Is it possible to simplfy this?

static if (is (T==Complex!double) || is (T==Complex!float) || is
(T==Complex!real))

```
Sep 18 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}
---
```
Sep 18 2019
```On Wednesday, 18 September 2019 at 11:25:21 UTC, Norm wrote:
I usually do something like the following:

Ah great. I was looking for "is(T == Complex!R, R)". :-) Thanks!
```
Sep 18 2019    Steven Schveighoffer <schveiguy gmail.com> writes:
```On 9/18/19 7:10 AM, berni wrote:
Is it possible to simplfy this?

static if (is (T==Complex!double) || is (T==Complex!float) || is
(T==Complex!real))

https://dlang.org/phobos/std_traits.html#TemplateOf

import std.traits : TemplateOf;

static if(__traits(isSame, TemplateOf!T, Complex))

-Steve
```
Sep 18 2019