The OpenD Programming Language

Algebraic.this

Construct an algebraic type from its subset.

  1. this(Algebraic!RhsTypes rhs)
    struct Algebraic(T__...)
    this
    (
    RhsTypes...
    )
    (
    Algebraic!RhsTypes rhs
    )
    if (
    !(
    is(Algebraic!RhsTypes == typeof(this))
    )
    &&
    allSatisfy!(Contains!AllowedTypes, Algebraic!RhsTypes.AllowedTypes)
    )
  2. this(T value)
  3. this(T value)
  4. this(T value)

Examples

alias Float = Variant!(float, double);
alias Int = Variant!(long, int);
alias Number = Variant!(Float.AllowedTypes, Int.AllowedTypes);

Float fp = 3.0;
Number number = fp; // constructor call
assert(number == 3.0);

Int integer = 12L;
number = Number(integer);
assert(number == 12L);

Meta