How to specialize a complex template with inheritance - C ++

I cannot find the correct syntax to specialize this template:

template <class Object, class Var, class Invert, class Step = Var, unsigned int FIXED = IW_GEOM_POINT> class TSin : public BasicTween<Object, Var> {... 

I want to save <Object> as a template parameter, but I specialize in all other parameters. I try like this:

  template <class Object> class TSin<Object, CIwVec2, int, CIwVec2, IW_GEOM_POINT> {... 

This gives errors.

Please can anyone provide the correct syntax to specialize the template and syntax for creating a custom version?

+4
source share
2 answers

The error is that you are overriding the class TSin . I do not think you can do this.

What you can do is declare a generic template and define class definitions:

 template <class Object, class Var, class Invert, class Step = Var, unsigned int FIXED = IW_GEOM_POINT> class TSin; template <class Object> class TSin<Object, CIwVec2, int, CIwVec2, IW_GEOM_POINT> {... 

or specialize class member definitions:

 template <class Object> void TSin<Object, CIwVec2, int, CIwVec2, IW_GEOM_POINT>::Foo(...) {... 

or declare a subclass:

 template <class Object, class Var, class Invert, class Step = Var, unsigned int FIXED = IW_GEOM_POINT> class TSin : public BasicTween<Object, Var> {... template <class Object> class SpecialTSin::public TSin<Object, CIwVec2, int, CIwVec2, IW_GEOM_POINT> {... 

I think the last option is the best.

0
source

I think your code should look like this: http://ideone.com/cvGy3

You need to define all types to instantiate the class.

+1
source

All Articles