hasType

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

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

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