Alias std.traits.ImplicitConversionTargets
alias ImplicitConversionTargets(T)
= AliasSeq!(byte,ubyte,short,ushort,int,uint,long,ulong,CentTypeList,float,double,real,char,wchar,dchar);
Parameters
Name | Description |
---|---|
T | The type to check |
Returns
An AliasSeq
with all possible target types of an implicit
conversion T
.
If T
is a class derived from Object
, the the result of
TransitiveBaseTypeTuple
is returned.
If the type is not a built-in value type or a class derived from
Object
, the an empty AliasSeq
is returned.
Note
The possible targets are computed more conservatively than the
language allows, eliminating all dangerous conversions. For example,
ImplicitConversionTargets!double
does not include float
.
See Also
Example
import std .meta : AliasSeq;
static assert(is(ImplicitConversionTargets!(ulong) == AliasSeq!(float, double, real)));
static assert(is(ImplicitConversionTargets!(int) == AliasSeq!(long, ulong, float, double, real)));
static assert(is(ImplicitConversionTargets!(float) == AliasSeq!(double, real)));
static assert(is(ImplicitConversionTargets!(double) == AliasSeq!(real)));
static assert(is(ImplicitConversionTargets!(char) == AliasSeq!(
wchar, dchar, byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real
)));
static assert(is(ImplicitConversionTargets!(wchar) == AliasSeq!(
dchar, short, ushort, int, uint, long, ulong, float, double, real
)));
static assert(is(ImplicitConversionTargets!(dchar) == AliasSeq!(
int, uint, long, ulong, float, double, real
)));
static assert(is(ImplicitConversionTargets!(string) == AliasSeq!(const(char)[])));
static assert(is(ImplicitConversionTargets!(void*) == AliasSeq!(void*)));
interface A {}
interface B {}
class C : A, B {}
static assert(is(ImplicitConversionTargets!(C) == AliasSeq!(Object, A, B)));
Authors
Walter Bright,
Tomasz Stachowiak (isExpressions
),
Andrei Alexandrescu,
Shin Fujishiro,
Robert Clipsham,
David Nadlinger,
Kenji Hara,
Shoichi Kato