Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std;
- struct Box(T)
- {
- T thing;
- this(T newThing)
- {
- thing = newThing;
- }
- }
- void main()
- {
- Box!int someInt = Box!int(5);
- Box!string someString = Box!string("flerrp");
- Box!bool someBool = Box!bool(true);
- static if (__traits(compiles, someInt.thing + 1))
- {
- writeln(someInt.thing + 5);
- }
- else static if (__traits(compiles, someString.thing ~= "asdf"))
- {
- someString.thing ~= " flirrp";
- writeln(someString.thing);
- }
- else static if (__traits(compiles, someBool.thing = false))
- {
- someBool.thing = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement