Jump to content
  • Advertisement
Sign in to follow this  
impulsionaudio

C++ Template Specialization in VC++ Express

This topic is 3611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Template specialization does not seem to work in VC++ Express. The errors make it seem like VC++ is just confused. Can someone please tell me what's wrong? template<typename T> class Spec1<T,double> {}; error C2143: syntax error : missing ';' before '<' error C2059: syntax error : '<' error C2143: syntax error : missing ';' before '{' error C2447: '{' : missing function header (old-style formal list?) template<typename T> class Spec2<T*> {}; same template<> class Spec3<float> {}; error C2143: syntax error : missing ';' before '<' error C2913: explicit specialization; 'Spec3' is not a specialization of a class template error C2059: syntax error : '<' error C2143: syntax error : missing ';' before '{' error C2447: '{' : missing function header (old-style formal list?) Thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by impulsionaudio
Template specialization does not seem to work in VC++ Express.


No, it works just fine.

Quote:
The errors make it seem like VC++ is just confused. Can someone please tell me what's wrong?


The errors tell you exactly what's wrong. You are not trying to specialize a non-existing class.

A specialization is:

template < class T, class F >
struct Spec {};

template < class T >
struct Spec<T, double> {};

template < class T >
struct Spec<T, float> {};


Same name, template parameters to class need to define all template parameters.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!