Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created January 18, 2019 14:01
Show Gist options
  • Save hadronized/10aa603f8556a07f0eb0b90ccc238082 to your computer and use it in GitHub Desktop.
Save hadronized/10aa603f8556a07f0eb0b90ccc238082 to your computer and use it in GitHub Desktop.
#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