Skip to content

Instantly share code, notes, and snippets.

@dnadlinger
Created August 9, 2015 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnadlinger/d04e6564c9964569a864 to your computer and use it in GitHub Desktop.
Save dnadlinger/d04e6564c9964569a864 to your computer and use it in GitHub Desktop.
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