XCode iOS 运算符新的自定义实现
XCode 对我的全局运算符 new 的实现发出警告:
void *operator new(size_t blocksize);
它说:'operator new' 缺少异常规范 'throw(std::bad_alloc)'
但我的实现并不打算抛出任何异常,我宁愿将其声明为
void *operator new(size_t blocksize) throw();
然而,后一个实现会导致错误:
声明中的异常规范与先前的声明不匹配
所以,问题是:我真的被迫(为了让 XCode 编译器平静下来)声明一个自定义的“operator new” ' 作为throw(std::bad_alloc) 即使它不会抛出任何异常?
XCode issues warning for my implementation of global operator new:
void *operator new(size_t blocksize);
It says: 'operator new' is missing exception specification 'throw(std::bad_alloc)'
But my implementation does not intend to throw any exception, and I'd rather declare it as
void *operator new(size_t blocksize) throw();
However, the latter implementation leads to an error:
Exception specification in declaration does not match previous declaration
So, the question is: am I really forced (to calm down XCode compiler) to declare a custom 'operator new' as throw(std::bad_alloc) even if it wont throw any exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你这样做:
http://developer.apple.com/library/ mac/#technotes/tn2185/_index.html
Yes you do:
http://developer.apple.com/library/mac/#technotes/tn2185/_index.html