首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么"typedef int (*pf)() throw(int);"这句话不符合C++错误规范

2012-04-13 
为什么typedef int (*pf)() throw(int)这句话不符合C++异常规范?C++标准文档上面说:typedef int (*pf)(

为什么"typedef int (*pf)() throw(int);"这句话不符合C++异常规范?
C++标准文档上面说:

typedef int (*pf)() throw(int); // ill-formed
—end example] A type denoted in an exception-specification shall not denote an incomplete type. A type
denoted in an exception-specification shall not denote a pointer or reference to an incomplete type, other
than void*, const void*, volatile void*, or const volatile void*.

我没有看明白为什么这句话是ill formed.
我在vc2010的编译器里面,发现编译时有一个warning:
 warning C4290: 忽略 C++ 异常规范,但指示函数不是 __declspec(nothrow)

这到底是什么意思呢?

[解决办法]
An exception-specification shall not appear in a typedef declaration.看标准说的这句吧
[解决办法]
这个定义太NB了。。。。直接连异常都考虑到了。。。可惜啊。。。语言需要重新设计哦。

热点排行