Created
August 9, 2015 19:14
-
-
Save dnadlinger/d04e6564c9964569a864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import core.stdc.stdio; | |
struct ThrowingCtor { | |
const char* name; | |
this(const char* name) { | |
printf("Constructing %s\n", name); | |
this.name = name; | |
throw new Exception("somebody set up us the bomb"); | |
} | |
~this() { | |
printf("Destroying %s\n", name); | |
} | |
} | |
struct ThrowingDtor { | |
const char* name; | |
this(const char* name) { | |
printf("Constructing %s\n", name); | |
this.name = name; | |
} | |
~this() { | |
printf("Destroying %s\n", name); | |
throw new Exception("for great justice"); | |
} | |
} | |
void foo(ThrowingDtor a, ThrowingDtor b, ThrowingCtor c) {} | |
void main() { | |
auto z = ThrowingDtor("z"); | |
foo(ThrowingDtor("a"), ThrowingDtor("b"), ThrowingCtor("c")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment