A
Alex
The following simplified code reproduces my problem:
#include <iostream>
struct MyTypeHolder
{
typedef int MyType;
};
struct MyOp
{
template<class T>
typename T::MyType doOp(typename T::MyType t)
{
return t + 1;
}
};
template <class Op>
class OpUser
{
public:
int getIntValue(int i)
{
return op_.doOp<MyTypeHolder>(i); // Line 23
}
private:
Op op_;
};
int main()
{
OpUser<MyOp> op_user;
std::cout << op_user.getIntValue(1) << std::endl;
return 0;
}
This compiles and works with VS.Net 2003 but not with g++ 3.4.3, which
I am assuming is following the standard more strictly.
The errors reported by g++ are:
test.cpp: In member function `int OpUser<Op>::getIntValue(int)':
test.cpp:23: error: expected primary-expression before '>' token
It seems to be treating the opening '<' character as a less than
rather than the start of an invocation of an explicit template method.
I don't really have control over the MyTypeHolder or MyOp classes, but
I can make changes to the OpUser class.
Does anyone know of a suitable fix for my problem?
Thanks,
Alex
#include <iostream>
struct MyTypeHolder
{
typedef int MyType;
};
struct MyOp
{
template<class T>
typename T::MyType doOp(typename T::MyType t)
{
return t + 1;
}
};
template <class Op>
class OpUser
{
public:
int getIntValue(int i)
{
return op_.doOp<MyTypeHolder>(i); // Line 23
}
private:
Op op_;
};
int main()
{
OpUser<MyOp> op_user;
std::cout << op_user.getIntValue(1) << std::endl;
return 0;
}
This compiles and works with VS.Net 2003 but not with g++ 3.4.3, which
I am assuming is following the standard more strictly.
The errors reported by g++ are:
test.cpp: In member function `int OpUser<Op>::getIntValue(int)':
test.cpp:23: error: expected primary-expression before '>' token
It seems to be treating the opening '<' character as a less than
rather than the start of an invocation of an explicit template method.
I don't really have control over the MyTypeHolder or MyOp classes, but
I can make changes to the OpUser class.
Does anyone know of a suitable fix for my problem?
Thanks,
Alex