我定义的函数:C++模板函数字符串类型不匹配?
template<class T>
inline void _assert(const string& message, T expected, T actual);
我一直在使用它来断言2个整数是平等的。但是,当我有:
_assert("Modifies(15, v) for v value", "h", varTable->getVarName(list.at(0)));
^returns std::string
它不工作:
Error 1 error C2782: 'void _assert(const std::string &,T,T)' : template parameter 'T' is ambiguous h:\dropbox\sch\cs3202\code\test\testqueryevaluator\testgetcandidatelist.cpp 183
为什么? 2个字符串不是同一类型?
因为一个参数是一个'为const char *',而另一种'的std :: string'。 – 2013-02-28 14:52:14