我定義的函數: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