[Insight-developers] vs8 and templates

Brad King brad.king at kitware.com
Wed Jun 22 13:00:10 EDT 2011


On 06/22/2011 12:44 PM, Alexandre GOUAILLARD wrote:
> now if I explicitly replace the return type like this in the definition:
> template< class T, unsigned int TVectorDimension >
> typename NumericTraits< T >::RealType
> Vector< T, TVectorDimension >
> ::GetSquaredNorm(void) const
> 
> then it compiles, but it seems a little bit brutal.

I think the case is related to the example below which fails similarly
in VS 2008.  Using an inline definition works.  I'm not aware of any
other workarounds.

-Brad


template <typename> struct A {};

template <typename T> struct B
{
   typedef A<T> Type; // using T works
   typedef const Type ConstType;
   Type& Get(void); // { return m; } // inline works
   ConstType& Get(void) const; // { return m; } // inline works
   Type m;
};

template <typename T>
typename B<T>::Type& B<T>::Get()
{
   return m;
}

template <typename T>
typename B<T>::ConstType& B<T>::Get() const
{
   return m;
}


More information about the Insight-developers mailing list