Skip to content

Instantly share code, notes, and snippets.

@ecatmur
Created August 8, 2014 10:15
Show Gist options
  • Save ecatmur/7f0487c219b473c5b3fa to your computer and use it in GitHub Desktop.
Save ecatmur/7f0487c219b473c5b3fa to your computer and use it in GitHub Desktop.
Contextual implicit conversion
# https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/rvbQiAx38Tg%5B1-25-false%5D
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf
struct C1 { enum class A{}; operator A(); explicit operator unsigned(); } c1;
struct C2 { operator char*(); explicit operator bool(); } c2;
struct C3 { operator int() = delete; operator unsigned(); } c3;
struct C4 { explicit operator int() = delete; operator unsigned(); } c4;
struct C5 { operator int(); explicit operator unsigned(); } c5;
void f() {
switch (c1) {}
switch (c2) {}
switch (c3) {}
switch (c4) {}
switch (c5) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment