Skip to content

Instantly share code, notes, and snippets.

@andyfriesen
Last active August 29, 2015 14:03
Show Gist options
  • Save andyfriesen/dfbc80983e548f0a965c to your computer and use it in GitHub Desktop.
Save andyfriesen/dfbc80983e548f0a965c to your computer and use it in GitHub Desktop.
It would be nice if this generated a compiler warning
#include <stdio.h>
enum Enumeration {
ENUM = 0,
};
struct S final {
explicit S(unsigned short id)
: S(ENUM, value)
{ }
S(Enumeration e, unsigned short id)
: value((e << 24) | id)
{ }
unsigned int value;
};
int main() {
S s(1);
printf("Value should be 1: %i\n", s.value);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment