c++ - Explicit member specialization using IBM Rational Rhapsody -


i want explicitly specialize member functions inside class using ibm rational rhapsody.

what have done far; created function inside regular class, marked template. marked cg::generate specification. prototype of template.

then created function. marked template. pointed function created above primary template under template parameters. filled implementation. here code rhapsody generates:

//## class myconvert class myconvert { ////    constructors , destructors    ////  public :  myconvert();  ~myconvert();  ////    operations    ////  //## operation strtox(char*,char*) template <typename t> inline static t strtox(char* in, char** end);  //## operation strtox(char*,char**) template <> inline double strtox<double>(char* in, char** end) {     //#[ operation strtox(char*,char**)     return strtod(in, end);                //#] } }; 

when compile this, this: error: explicit specialization in non-namespace scope 'class myconvert'

explicit specialization should implemented outside of class definition, this:

//## class myconvert class myconvert {     ////    constructors , destructors    ////  public :      myconvert();      ~myconvert();      ////    operations    ////      //## operation strtox(char*,char*)     template <typename t> inline static t strtox(char* in, char** end); };  //## operation strtox(char*,char**) template <> inline double myconvert::strtox<double>(char* in, char** end) {     //#[ operation strtox(char*,char**)     return strtod(in, end);                //#] } 

how achieve using rhapsody?

it's not precisely answer workaround have specialized functions. surely, trick.

instead of defining functions inside class, define them inside package. way, implementation outside of class scope. class member functions can still access functions defined within package.

i posted detailed explanation blog. if interested: http://kaskavalci.com/?p=323


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -