【问题标题】:overloaded templated functions ambiguity issue重载模板化函数歧义问题
【发布时间】:2012-10-02 14:45:37
【问题描述】:

有人能找到第一次重载和所需功能之间的区别吗?如果我注释掉 Python 规范,编译没问题,但我在其他地方需要它。真是让人抓狂……

template<typename TN>
void fromVectorTo(const std::vector<TN> & input, xlw::impl::XlfOper<xlw::LPXLFOPER> * output){....}
template<typename TN>
void fromVectorTo(const std::vector<TN> & input, PyObject ** output){...}

error C2665: 'pal::fromVectorTo' : none of the 2 overloads could convert all the argument types
8>        myPython.h(73): could be 'void pal::fromVectorTo<double>(const std::vector<_Ty> &,PyObject **)'
8>        with
8>        [
8>            _Ty=double
8>        ]
8>        myXLW.h(102): or       'void pal::fromVectorTo<double>(const std::vector<_Ty> &,xlw::impl::XlfOper<LPOPER_TYPE> *)'
8>        with
8>        [
8>            _Ty=double,
8>            LPOPER_TYPE=xlw::LPXLFOPER
8>        ]
8>        while trying to match the argument list '(const std::vector<_Ty>, xlw::impl::XlfOper<LPOPER_TYPE> *)'
8>        with
8>        [
8>            _Ty=double
8>        ]
8>        and
8>        [
8>            LPOPER_TYPE=xlw::LPXLFOPER
8>        ]

【问题讨论】:

    标签: c++ templates compiler-errors overloading


    【解决方案1】:

    看起来这是一个编译器错误 - 错误消息一定是错误的。当我使用模板类的部分专业化 + 做其他修改时,问题似乎消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      相关资源
      最近更新 更多