Skip to content

Instantly share code, notes, and snippets.

@aita
Created August 25, 2011 02:31
Show Gist options
  • Save aita/1169833 to your computer and use it in GitHub Desktop.
Save aita/1169833 to your computer and use it in GitHub Desktop.
#include <cstdlib>
#include <iostream>
struct Die {
template <typename T>
operator T() {
std::cout << "Die!!" << std::endl;
std::exit(1);
}
} die;
int main()
{
int a = 0 or die;
return 0;
}
@aita
Copy link
Author

aita commented Aug 25, 2011

$ g++ die.cc
$ ./a.out
Die!!
$ echo $?
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment