【C++错误处理】VC6中关于bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments

简介: 作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ 今天在用VC6调试一个别人写的示例程序时,发现了这么一个错误:   bool __cdecl std::isdigit(_E,const class std::locale &)' : ex...

作者:gnuhpc
出处:
http://www.cnblogs.com/gnuhpc/

今天在用VC6调试一个别人写的示例程序时,发现了这么一个错误:

 

bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments

 

出错的代码:

         

[cpp] view plaincopy

1.  return std::isdigit(_expr[_pos]) != 0; 

2.          bool (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之间的差别问题。

作者:gnuhpc
出处:
http://www.cnblogs.com/gnuhpc/

 


               作者:gnuhpc
               出处:http://www.cnblogs.com/gnuhpc/
               除非另有声明,本网站采用知识共享“署名 2.5 中国大陆”许可协议授权。


分享到:

目录
相关文章
|
1月前
|
存储 安全 编译器
【C++ 17 新功能 std::visit 】深入解析 C++17 中的 std::visit:从原理到实践
【C++ 17 新功能 std::visit 】深入解析 C++17 中的 std::visit:从原理到实践
70 0
|
9天前
|
存储 编译器 C++
【C++成长记】C++入门 | 类和对象(中) |拷贝构造函数、赋值运算符重载、const成员函数、 取地址及const取地址操作符重载
【C++成长记】C++入门 | 类和对象(中) |拷贝构造函数、赋值运算符重载、const成员函数、 取地址及const取地址操作符重载
|
16天前
|
编译器 C++
|
18天前
|
编译器 C语言 C++
【C++的奇迹之旅(二)】C++关键字&&命名空间使用的三种方式&&C++输入&输出&&命名空间std的使用惯例
【C++的奇迹之旅(二)】C++关键字&&命名空间使用的三种方式&&C++输入&输出&&命名空间std的使用惯例
|
29天前
|
安全 程序员 C++
【C++ 基本知识】现代C++内存管理:探究std::make_系列函数的力量
【C++ 基本知识】现代C++内存管理:探究std::make_系列函数的力量
101 0
|
30天前
|
设计模式 安全 C++
【C++ const 函数 的使用】C++ 中 const 成员函数与线程安全性:原理、案例与最佳实践
【C++ const 函数 的使用】C++ 中 const 成员函数与线程安全性:原理、案例与最佳实践
71 2
|
1月前
|
存储 安全 编译器
【C++ 函数设计的艺术】深挖 C++ 函数参数的选择 智能指针与 std::optional:最佳实践与陷阱
【C++ 函数设计的艺术】深挖 C++ 函数参数的选择 智能指针与 std::optional:最佳实践与陷阱
109 0
|
1月前
|
算法 测试技术 编译器
【C++ 基本类型 bool 】深入探索C++中的布尔类型Boolean(二 )
【C++ 基本类型 bool 】深入探索C++中的布尔类型Boolean
27 0
|
1月前
|
程序员 编译器 C语言
【C++ 基本类型 bool 】深入探索C++中的布尔类型Boolean(一)
【C++ 基本类型 bool 】深入探索C++中的布尔类型Boolean
40 0
|
1月前
|
安全 算法 编译器
【C++中的const函数】何时与如何正确声明使用C++ const函数(三)
【C++中的const函数】何时与如何正确声明使用C++ const函数
26 0