numtrait.cpp

来自「数值计算工具库,C语言编写的,可以直接调用.」· C++ 代码 · 共 38 行

CPP
38
字号
#ifdef BZ_NO_TYPENAME
 #define typename
#endif


// BZ_USE_NUMTRAIT

template<class T_numtype>
class SumType {
public:
    typedef T_numtype T_sumtype;
};

template<>
class SumType<char> {
public:
    typedef int       T_sumtype;
};

template<class T>
class Vector {
};

template<class T>
Vector<typename SumType<T>::T_sumtype>
sum(Vector<T>)
{
    return Vector<typename SumType<T>::T_sumtype>();
}

int main()
{
    Vector<float> x;
    sum(x);
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?