parsing error invoking static function on object instance?
I'm wondering if the following code should be considered valid c++, gcc
and clang both choke on it while Microsoft and the embedded compiler
(green hills) our project uses seem to parse this without problems. The
foo().Bar(); line of code is what gives gcc and clang trouble. It appears
gcc thinks the < is a less than operator instead of specifying a template
argument. If Bar is changed to not be a template function gcc accepts it.
class Test1
{
public:
template<typename U>
static void Bar() {}
};
template<typename T>
class Test2
{
public:
Test2()
{
foo().Bar<int>();
}
Test1 foo() { return t; }
Test1 t;
};
int main()
{
Test2<int> t;
}
From my research calling a static member function on an object instance is
valid c++. So what are you thoughts? Here is gcc's error:
Error.cpp: In constructor 'Test2<T>::Test2()':
Error.cpp:14:17: error: expected primary-expression before 'int'
foo().Bar<int>();
^
Error.cpp:14:17: error: expected ';' before 'int'
No comments:
Post a Comment