View source code
Display the source code in std/traits.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Alias std.traits.AllImplicitConversionTargets

alias AllImplicitConversionTargets(T) = AliasSeq!(byte,ubyte,short,ushort,int,uint,long,ulong,CentTypeList,float,double,real,char,wchar,dchar);

Parameters

NameDescription
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 result of TransitiveBaseTypeTuple is returned.

If the type is not a built-in value type or a class derived from Object, an empty AliasSeq is returned.

See Also

isImplicitlyConvertible

Example

import std.meta : AliasSeq;

static assert(is(AllImplicitConversionTargets!(ulong) == AliasSeq!(long, float, double, real)));
static assert(is(AllImplicitConversionTargets!(int) == AliasSeq!(uint, long, ulong, float, double, real)));
static assert(is(AllImplicitConversionTargets!(float) == AliasSeq!(double, real)));
static assert(is(AllImplicitConversionTargets!(double) == AliasSeq!(float, real)));

static assert(is(AllImplicitConversionTargets!(char) == AliasSeq!(
    wchar, dchar, byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real
)));
static assert(is(AllImplicitConversionTargets!(wchar) == AliasSeq!(
    dchar, short, ushort, int, uint, long, ulong, float, double, real
)));
static assert(is(AllImplicitConversionTargets!(dchar) == AliasSeq!(
    int, uint, long, ulong, float, double, real
)));

static assert(is(AllImplicitConversionTargets!(string) == AliasSeq!(const(char)[])));
static assert(is(AllImplicitConversionTargets!(void*) == AliasSeq!(void*)));

interface A {}
interface B {}
class C : A, B {}

static assert(is(AllImplicitConversionTargets!(C) == AliasSeq!(Object, A, B)));
static assert(is(AllImplicitConversionTargets!(const C) == AliasSeq!(const Object, const A, const B)));
static assert(is(AllImplicitConversionTargets!(immutable C) == AliasSeq!(
    immutable Object, immutable A, immutable B
)));

interface I : A, B {}

static assert(is(AllImplicitConversionTargets!(I) == AliasSeq!(A, B)));
static assert(is(AllImplicitConversionTargets!(const I) == AliasSeq!(const A, const B)));
static assert(is(AllImplicitConversionTargets!(immutable I) == AliasSeq!(
    immutable A, immutable B
)));

Authors

Walter Bright, Tomasz Stachowiak (isExpressions), Andrei Alexandrescu, Shin Fujishiro, Robert Clipsham, David Nadlinger, Kenji Hara, Shoichi Kato

License

Boost License 1.0.