hasType

Tests if the algebraic type stores a value of a certain data type.

  1. bool hasType(in ref TaggedAlgebraic!U ta)
    bool
    hasType
    (
    T
    U
    )
    ()
  2. bool hasType(in TaggedAlgebraic!U ta)

Examples

1 union Fields {
2 	int number;
3 	string text;
4 }
5 
6 TaggedAlgebraic!Fields ta = "test";
7 
8 assert(ta.hasType!string);
9 assert(!ta.hasType!int);
10 
11 ta = 42;
12 assert(ta.hasType!int);
13 assert(!ta.hasType!string);

Meta