大佬教程收集整理的这篇文章主要介绍了c – 模板上的宏,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
std::vector<T> operator - (const std::vector<T>& data1,const std::vector<T>& data2); std::vector<T> operator * (const std::vector<T>& data1,const std::vector<T>& data2); std::vector<T> operator & (const std::vector<T>& data1,const std::vector<T>& data2);
….等等.除了运算符之外,所有这些函数都具有完全相同的定义,因此我尝试编写这样的宏
#define _BINARY_OP_ON_DATASET (OP_TYPE) template <typename T> \ std::vector<T> operator OP_TYPE (const std::vector<T>& data1,const std::vector<T>& data2)\ {\ std::vector<T> result;\ result.push_BACk(data1.begin().val OP_TYPE data1.begin().val)/*sample implementation*/\ return result;\ } _BINARY_OP_ON_DATASET (&) _BINARY_OP_ON_DATASET (+)
而且我得到了一堆错误
Error 1 error C2833: 'operator OP_TYPE' is not a recognized operator or type Error 2 error C2988: unrecognizable template declaration/deFinition Error 3 error C2059: Syntax error : 'newline' Error 5 error C2143: Syntax error : missing ';' before '<' Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
…和更多
任何人都可以看到这个问题是什么?
谢谢你的帮助.
简历
以上是大佬教程为你收集整理的c – 模板上的宏全部内容,希望文章能够帮你解决c – 模板上的宏所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。