views:

80

answers:

1

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
 }
};
+5  A: 

VS is being kind.

return Factory<MC, MT>::template Register<MC>(Type); should work under both compilers.

Logan Capaldo
Wow. 4 mn to get the answer ("::template " did the trick).I'm impressed.Oh, and thanks!!
For the record, the compiler is "supposed" to see Factory<MC, MT>::Register<MC>(Type) without the template as Factory<MC, MT>::Register < MC > (Type). VS tries to be more helpful (arguably more than it should), but that's why g++ choked.
Logan Capaldo
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, ...
Max Lybbert