У меня есть подобный код:ожидаются первичное выражение, прежде '>' лексема
class Client2ServerProtocol {
};
class ProtocolHelper {
public:
template<class ProtocolClass>
int GetProtocolId() {
return -1;
}
};
template<> inline int
ProtocolHelper::GetProtocolId<Client2ServerProtocol>() {
return 1;
}
template<typename PROTOCOL_HELPER>
class Dispatcher {
public:
template<typename PROTOCOL_CLASS>
void Subscribe(int msgId) {
int protoId = helper.GetProtocolId<PROTOCOL_CLASS>();
printf("Subscribe protoId %d, msgId %d", protoId, msgId);
}
PROTOCOL_HELPER helper;
};
int main() {
Dispatcher<ProtocolHelper> dispatcher;
dispatcher.Subscribe<Client2ServerProtocol>(1);
return 0;
}
Он успешно (и работает) под MSVC компилирует, но GCC жалуется недействительным синтаксис:
test.cc:23:56: error: expected primary-expression before ‘>’ token int protoId = helper.GetProtocolId();
test.cc:23:58: error: expected primary-expression before ‘)’ token
Что я делаю неправильно? int protoId = helper.GetProtocolId();