Skip to content

Instantly share code, notes, and snippets.

@ashgti
Last active December 12, 2015 00:58
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 ashgti/4687317 to your computer and use it in GitHub Desktop.
Save ashgti/4687317 to your computer and use it in GitHub Desktop.
Don't do this ever please. If you have to, please comment it.
#include <stdio.h>
struct foo {
struct dummy {
int i;
};
typedef int dummy::*_bool;
foo(int f) : f_(f) {}
int f_;
operator _bool() const {
return f_ ? &dummy::i: 0;
}
};
int main() {
foo bar(3);
if (bar) {
puts("yes");
} else {
puts("no");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment