What I try to do is to iterate over two variables using template
metaprogramming . I've specialized it such that when it reaches the end
of a row ot starts on the next and when it reaches the last row it stops..
At least that's what I thought I did, but VC71 says "warning C4717:
'LOOP<0,1>::DO' : recursive on all control paths, function will cause
runtime stack overflow".
What's wrong?
Here's the code:
template<int M, int N>
class LOOP {
private:
template<int I, int J>
class INNER {
public:
static inline void DO() {
cout << "(" << I << "," << J << ") ";
LOOP<I+1, J>::DO();
}
};
template<int J>
class INNER<M, J> {
public:
static inline void DO() {
LOOP<0, J+1>::DO();
}
};
template<int I>
class INNER<I, N> {
public:
static inline void DO() {
}
};
public:
static inline void DO() {
INNER<0, 0>::DO();
}
};
metaprogramming . I've specialized it such that when it reaches the end
of a row ot starts on the next and when it reaches the last row it stops..
At least that's what I thought I did, but VC71 says "warning C4717:
'LOOP<0,1>::DO' : recursive on all control paths, function will cause
runtime stack overflow".
What's wrong?
Here's the code:
template<int M, int N>
class LOOP {
private:
template<int I, int J>
class INNER {
public:
static inline void DO() {
cout << "(" << I << "," << J << ") ";
LOOP<I+1, J>::DO();
}
};
template<int J>
class INNER<M, J> {
public:
static inline void DO() {
LOOP<0, J+1>::DO();
}
};
template<int I>
class INNER<I, N> {
public:
static inline void DO() {
}
};
public:
static inline void DO() {
INNER<0, 0>::DO();
}
};
Comment