Created
May 30, 2011 19:33
-
-
Save Pet3ris/999358 to your computer and use it in GitHub Desktop.
C++ FOR macro
This file contains 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
Old macro for use in programming competitions. Iterates over numbers and iterators, choosing the right comparison for each range. |
This file contains 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
template <class T, bool B> struct cmp_ { inline static bool cmp(T a, T b) { return a < b; } }; | |
template <class T> struct cmp_<T, false> { inline static bool cmp(T a, T b) { return a != b; } }; | |
#define FOR(i, b, e) for (typeof(b) i = (b); cmp_< typeof(b), numeric_limits< typeof(b) >::is_specialized >::cmp(i, e); ++i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment