Skip to content

Instantly share code, notes, and snippets.

@warmist
Last active November 24, 2015 19:50
Show Gist options
  • Save warmist/711522d79a8c327bac8f to your computer and use it in GitHub Desktop.
Save warmist/711522d79a8c327bac8f to your computer and use it in GitHub Desktop.
Automatic enumeration iteration generation formation C++'ination.
#define enum_helper(type_name,first,last) type_name operator++(type_name & x) {return x = type_name(std::underlying_type<type_name>::type(x) + 1); }\
type_name operator*(type_name c) {return c;}\
type_name begin(type_name r) {return type_name:: first;}\
type_name end(type_name r) {return type_name:: last;}
enum class thingy
{
a,b,c,d,e,f,g
};
enum_helper(thingy,a,g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment