A
Amon Tse
I have the following code which is unable to compile in VC6:
#include <iostream>
template<size_t target, size_t idx = 0>
struct _Iterator
{
enum
{
value = (target == idx) ? idx : _Iterator<target, idx+1>::value
};
};
int main()
{
std::cout << _Iterator<3>::value << std::endl;
// the expected result is 3
return 0;
}
The compilation error is
fatal error C1202: recursive type or function dependency context too
complex
This likely could be solved if I had switched to use VC7.1. However, I
have no luck that I must use VC6. Could anyone offer me a workaround?
Thanks in advance.
#include <iostream>
template<size_t target, size_t idx = 0>
struct _Iterator
{
enum
{
value = (target == idx) ? idx : _Iterator<target, idx+1>::value
};
};
int main()
{
std::cout << _Iterator<3>::value << std::endl;
// the expected result is 3
return 0;
}
The compilation error is
fatal error C1202: recursive type or function dependency context too
complex
This likely could be solved if I had switched to use VC7.1. However, I
have no luck that I must use VC6. Could anyone offer me a workaround?
Thanks in advance.