00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef META_MATH_LOOP3_INCLUDE
00013 #define META_MATH_LOOP3_INCLUDE
00014
00015
00016
00017 namespace meta_math {
00018
00019 template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1,
00020 std::size_t Index2, std::size_t Max2>
00021 struct loop3
00022 {
00023 static std::size_t const index0= Index0 - 1, next_index0= Index0,
00024 index1= Index1 - 1, next_index1= Index1,
00025 index2= Index2 - 1, next_index2= Index2 + 1;
00026 };
00027
00028
00029 template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1,
00030 std::size_t Max2>
00031 struct loop3<Index0, Max0, Index1, Max1, Max2, Max2>
00032 {
00033 static std::size_t const index0= Index0 - 1, next_index0= Index0,
00034 index1= Index1 - 1, next_index1= Index1 + 1,
00035 index2= Max2 - 1, next_index2= 1;
00036 };
00037
00038
00039 template <std::size_t Index0, std::size_t Max0, std::size_t Max1, std::size_t Max2>
00040 struct loop3<Index0, Max0, Max1, Max1, Max2, Max2>
00041 {
00042 static std::size_t const index0= Index0 - 1, next_index0= Index0 + 1,
00043 index1= Max1 - 1, next_index1= 1,
00044 index2= Max2 - 1, next_index2= 1;
00045 };
00046
00047
00048 template <std::size_t Max0, std::size_t Max1, std::size_t Max2>
00049 struct loop3<Max0, Max0, Max1, Max1, Max2, Max2>
00050 {
00051 static std::size_t const index0= Max0 - 1,
00052 index1= Max1 - 1,
00053 index2= Max2 - 1;
00054 };
00055
00056
00057
00058
00059 #if 0
00060
00061
00062
00063
00064
00065
00066 template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1,
00067 std::size_t Index2, std::size_t Max2>
00068 struct loop3_trace : public loop3<Index0, Max0, Index1, Max1, Index2, Max2>
00069 {
00070 typedef loop3<Index0, Max0, Index1, Max1, Index2, Max2> base;
00071 typedef loop3_trace<base::next_index0, Max0, base::next_index1, Max1, base::next_index2, Max2> next_t;
00072
00073 void operator() ()
00074 {
00075 std::cout << this->index0 << " : " << this->index1 << " : " << this->index2 << "\n";
00076 next_t() ();
00077 }
00078 };
00079
00080
00081 template <std::size_t Max0, std::size_t Max1, std::size_t Max2>
00082 struct loop3_trace<Max0, Max0, Max1, Max1, Max2, Max2>
00083 : public loop3<Max0, Max0, Max1, Max1, Max2, Max2>
00084 {
00085 void operator() ()
00086 {
00087 std::cout << this->index0 << " : " << this->index1 << " : " << this->index2 << "\n";
00088 }
00089 };
00090
00091 #endif
00092
00093 }
00094
00095 #endif // META_MATH_LOOP3_INCLUDE