Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 18, 2019 static if (is (T==Complex)) | ||||
---|---|---|---|---|
| ||||
Is it possible to simplfy this?
>static if (is (T==Complex!double) || is (T==Complex!float) || is (T==Complex!real))
|
September 18, 2019 Re: static if (is (T==Complex)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | 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}
---
|
September 18, 2019 Re: static if (is (T==Complex)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norm | 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!
|
September 18, 2019 Re: static if (is (T==Complex)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | 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 |
Copyright © 1999-2021 by the D Language Foundation