AllImplicitConversionTargets

template AllImplicitConversionTargets (
T
) {}

Parameters

T

The type to check

Return Value

An std.meta.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 std.meta.AliasSeq is returned.

Examples

import std.meta : AliasSeq;

static assert(is(AllImplicitConversionTargets!(ulong) == AliasSeq!(long, float, double, real)));
static assert(is(AllImplicitConversionTargets!(int) == AliasSeq!(dchar, 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!(byte, ubyte, short, ushort, wchar, int, dchar, uint, long,
        ulong, float, double, real)
));
static assert(is(AllImplicitConversionTargets!(wchar) == AliasSeq!(
    short, ushort, dchar, 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!(int*) == 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
)));

See Also

Meta