C++ 使用IBMRationalRhapsody的显式成员专门化

C++ 使用IBMRationalRhapsody的显式成员专门化,c++,template-specialization,rhapsody,C++,Template Specialization,Rhapsody,我想使用IBMRationalRhapsody显式地专门化类中的一些成员函数 到目前为止我所做的; 我在一个常规类中创建了一个函数,将其标记为模板。标记为CG::生成到规范。这将是模板的原型 然后我创建了另一个函数。将其标记为模板。将我在上面创建的函数指定为模板参数下的主模板。填充执行。以下是Rhapsody生成的代码: //## class MyConvert class MyConvert { //// Constructors and destructors //// pub

我想使用IBMRationalRhapsody显式地专门化类中的一些成员函数

到目前为止我所做的; 我在一个常规类中创建了一个函数,将其标记为模板。标记为CG::生成规范。这将是模板的原型

然后我创建了另一个函数。将其标记为模板。将我在上面创建的函数指定为模板参数下的主模板。填充执行。以下是Rhapsody生成的代码:

//## class MyConvert
class MyConvert {
////    Constructors and 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);           
    //#]
}
};

如何使用Rhapsody实现这一点?

这不是确切的答案,而是一种具有专门功能的解决方法。当然,它起到了作用

不要在类中定义函数,而是在包中定义它们。这样,实现将在类范围之外。类成员函数仍然可以访问包中定义的函数

我在我的博客上贴了详细的解释。如有兴趣:

//## class MyConvert
class MyConvert {
    ////    Constructors and 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);           
    //#]
}