I have the following (simplified) code:
#include <iostream>
class Foo {
public:
template<class T>
static size_t f() {
return sizeof(T);
}
};
template<class A>
class Bar {
public:
template<class B>
static void f(B const& b) {
std::cout << A::f<B>() << std::endl;
}
};
int main() {
Bar<Foo>::f(3.0);
return 0;
}
It compiles fine in MSVC, but in GCC (5.2.1) it gives the following error:
main.cpp:16:26: error: expected primary-expression before ‘>’ token
std::cout << A::f<B>() << std::endl;
^
(followed by a few hundred lines of cout-related errors). I suppose it doesn't realize that A::f
can be a template function? Is it breaking anything in the standard?