elabret.cpp
来自「数值计算工具库,C语言编写的,可以直接调用.」· C++ 代码 · 共 40 行
CPP
40 行
#ifdef BZ_NO_TYPENAME
#define typename
#endif
// Template-qualified return type, necessary for type promotion on vectors
// BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
template<class X, class Y>
struct promote_trait {
typedef X T;
};
template<>struct promote_trait<int, float> {
typedef float T;
};
template<class T>
class Vector {
public:
Vector() { }
};
template<class X, class Y>
Vector<typename promote_trait<X,Y>::T> operator+(const Vector<X>&,
const Vector<Y>&)
{
return Vector<typename promote_trait<X,Y>::T>();
}
int main()
{
Vector<int> x;
Vector<float> y;
Vector<float> z = x + y;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?