status of "isComplex" in traits ?? (we have isFloatingPoint, for example)

Paul Backus snarwin at gmail.com
Wed Aug 18 17:49:53 UTC 2021


On Wednesday, 18 August 2021 at 17:36:48 UTC, H. S. Teoh wrote:
> There's no need, you could just write:
>
> 	static if (is(T == Complex!U, U)) {
> 		// You can refer to U here to get at the type Complex
> 		// was instantiated with.
> 	}
>
> This has the added benefit of unpacking the parameter U for you.

Well, there's no need assuming you already know how to use is() 
expressions to pattern-match types, which is a big assumption.

IMO it would not be totally unreasonable to add an 
std.complex.isComplex template for this purpose.


More information about the Digitalmars-d mailing list