M
Martin Magnusson
It seems that the following code is not valid, but I need to find a
workaround. Both gcc and Comeau tells me that j can't be used as a
template argument, even though it's declared as a const unsigned. Is
there a way to get around this?
template< unsigned M >
class Tree
{
public:
Tree()
{
for (unsigned i = 0; i < M; ++i)
{
const unsigned j = i;
Compare<j> c; // j cannot be used as template argument
}
}
private:
template< unsigned N >
class Compare
{
public:
bool operator()( int i1, int i2 )
{ return i1 < i2; }
};
};
int main()
{
Tree<3> t;
return 0;
}
workaround. Both gcc and Comeau tells me that j can't be used as a
template argument, even though it's declared as a const unsigned. Is
there a way to get around this?
template< unsigned M >
class Tree
{
public:
Tree()
{
for (unsigned i = 0; i < M; ++i)
{
const unsigned j = i;
Compare<j> c; // j cannot be used as template argument
}
}
private:
template< unsigned N >
class Compare
{
public:
bool operator()( int i1, int i2 )
{ return i1 < i2; }
};
};
int main()
{
Tree<3> t;
return 0;
}