Jon Stewart on Wed, 2 Mar 2005 23:39:48 -0600 (CST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
[ALACPP] the pleasure of counting |
#include <iostream> template<int N> struct Int2Type { enum { value = N }; operator int() const { return N; } }; typedef struct { char a[20]; } RT2; char defined(int); template <int N, int LINE, bool b> struct Counter; template <int N, int LINE> struct Counter<N, LINE, false> { enum { value = N-1 }; }; template <int N, int LINE> struct Counter<N, LINE, true> { enum { value = Counter< N+1, LINE, (sizeof(defined(Int2Type<N>())) != sizeof(char)) >::value }; }; RT2 defined(Int2Type< Counter< 0, (int)(__LINE__), true >::value >); RT2 defined(Int2Type< Counter< 0, (int)(__LINE__), true >::value >); struct STFU { enum { value = __LINE__ }; }; int main(int, char *[]) { std::cout << Counter<0, STFU::value, true>::value << std::endl; return 0; } -- Jon Stewart stew1@xxxxxxxxxxx _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp