View difference between Paste ID: Rx2xZDvb and 6fPfi8ck
SHOW: | | - or go back to the newest paste.
1
import std;
2
3
struct Box(T)
4
{
5
	T thing;
6
7
	this(T newThing)
8
	{
9
		thing = newThing;
10
	}
11
}
12
13
void main()
14
{
15-
	Box!int someInt = Box!T(5);
15+
	Box!int someInt = Box!int(5);
16
	Box!string someString = Box!string("flerrp");
17
	Box!bool someBool = Box!bool(true);
18
19
	static if (__traits(compiles, someInt.thing + 1))
20
	{
21
		writeln(someInt.thing + 5);
22
	}
23
	else static if (__traits(compiles, someString.thing ~= "asdf"))
24
	{
25
		someString.thing ~= " flirrp";
26
		writeln(someString.thing);
27
	}
28
	else static if (__traits(compiles, someBool.thing = false))
29
	{
30
		someBool.thing = false;
31
	}
32
}