Hi,
I'm puzzled here, and kindly request your help. VC2005SP1 swallows this (stripped out) code but gcc 4.0.1 bails out... Please point me the obvious mistake ? TIA!
template<typename BCT, typename UIDT>
class Factory
{
public:
template<typename CT>
bool Register(UIDT UniqueID)
{
if (UniqueID > 10)
return(false);
CreateObject2<BCT, CT>;
return(true);
}
};
template <typename MC, typename MT>
class Manager : public Factory<MC, MT>
{
public:
bool RegisterType(const MT Type, const std::string TypeName)
{
return Factory<MC, MT>::Register<MC>(Type); // gcc claims "expected primary-expression before '>' at this point
}
};
From stackoverflow
-
VS is being kind.
return Factory<MC, MT>::template Register<MC>(Type);should work under both compilers.Logan Capaldo : For the record, the compiler is "supposed" to see Factory::Register (Type) without the template as Factory ::Register < MC > (Type). VS tries to be more helpful (arguably more than it should), but that's why g++ choked. Max Lybbert : And, for the record, g++ once had this "feature" but removed it because code written without "template" and "typename" would compile on g++ but not VC at the time, ...
0 comments:
Post a Comment