Created
January 18, 2019 14:01
-
-
Save hadronized/10aa603f8556a07f0eb0b90ccc238082 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <iostream> | |
#include <string> | |
struct BordelLand { | |
BordelLand(bool x): tag(Graffiti::A), a(x) {} | |
BordelLand(char x): tag(Graffiti::B), b(x) {} | |
BordelLand(float x): tag(Graffiti::C), c(x) {} | |
template <typename F> void pattern_a(F f) { | |
if (tag == Graffiti::A) { | |
auto& ref = a; | |
f(ref); | |
} | |
} | |
template <typename F> void pattern_b(F f) { | |
if (tag == Graffiti::B) { | |
auto& ref = b; | |
f(ref); | |
} | |
} | |
template <typename F> void pattern_c(F f) { | |
if (tag == Graffiti::C) { | |
auto& ref = c; | |
f(ref); | |
} | |
} | |
private: | |
enum Graffiti { A, B, C } tag; | |
union { | |
bool a; | |
char b; | |
float c; | |
}; | |
}; | |
int main() { | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment