今天在用VC6調試一個别人寫的示例程式時,發現了這麼一個錯誤:
bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments
出錯的代碼:
1. return std::isdigit(_expr[_pos]) != 0;
2. <b>bool</b> (isdigit)(_E _C, const locale& _L)
3.
4. while (_pos < _expr.length() && std::isdigit(_expr[_pos]) != 0)
MSDN中 對isdigit的定義如下:
template<class E>;
bool isdigit(E c, const locale& loc) const;
The template function returns use_facet< ctype<E>; >;(loc). is(ctype<E>;:: digit, c).
沒有怎麼看懂為什麼MS把這麼簡單的一個函數定義的如此複雜...
後來看一個老外的解決方法:
you are using the std template version is isdigit which apparently requires two parameters. remove the std:: namespace and the compiler will use the standard C version that only requires one parmeter.
自然就解決了VC6标準模闆和标準C之間的差别問題。