1 auto a = Event( 1, [ 0.1, 0.2, 0.3 ] );
2 auto gg = a.as!(double[]);
3 assert( gg == [ 0.1, 0.2, 0.3 ] );
4 auto b = Event( 1, "some string"w );
5 auto nn = b.as!wstring;
6 assert( nn == "some string"w );
7 auto c = Event( 1, "some str" );
8 auto d = shared Event( c );
9 assert( c.as!string == "some str" );
10 assert( d.as!string == "some str" );
11 assert( c.code == d.code );
12
13 struct TestStruct { double x, y; string info; immutable(int)[] data; }
14
15 auto ts = TestStruct( 10.1, 12.3, "hello", [1,2,3,4] );
16 auto e = Event( 1, ts );
17
18 auto f = shared Event( e );
19 auto g = immutable Event( e );
20 auto h = shared const Event( e );
21
22 assert( e.as!TestStruct == ts );
23 assert( f.as!TestStruct == ts );
24 assert( g.as!TestStruct == ts );
25 assert( h.as!TestStruct == ts );
26
27 auto l = Event( f );
28 auto m = Event( g );
29 auto n = Event( h );
30
31 assert( l.as!TestStruct == ts );
32 assert( m.as!TestStruct == ts );
33 assert( n.as!TestStruct == ts );
1 static struct TestStruct { double x, y; string info; immutable(int)[] data; }
2 auto ts = TestStruct( 3.14, 2.7, "hello", [ 2, 3, 4 ] );
3
4 auto a = Event( 8, ts );
5 auto ac = const Event( a );
6 auto ai = immutable Event( a );
7 auto as = shared Event( a );
8 auto acs = const shared Event( a );
9
10 assert( a.as!TestStruct == ts );
11 assert( ac.as!TestStruct == ts );
12 assert( ai.as!TestStruct == ts );
13 assert( as.as!TestStruct == ts );
14 assert( acs.as!TestStruct == ts );