为什么没有bada需要scoped_ptr? [英] Why didn't bada require scoped_ptr?

查看:229
本文介绍了为什么没有bada需要scoped_ptr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bada C ++风格指南/架构使用

为什么它们不需要使用scoped_ptr?



但我怀疑他们的答案将会是:在页面顶部附近以粗体书写的相同:没有两阶段构造,资源泄漏。



我不同意这个评估;真正的问题是他们的 ComplexClass 构造函数体不是异常安全的。在这种情况下,代码将具有更强大的 与简单的RAII,,特别是它缩放



关于为什么他们不需要scoped_ptr:我想象这是一个C ++ 03文档,谈论C ++,而不是第三方库。


The bada C++ style guide/architecture uses a two-step initialization of C++ objects.

Why did they not simply require the use of scoped_ptr?

解决方案

You should ask them, because I am not a psychic.

However I suspect their answer will be the same as is written in bold near the top of that page: "Without two-phase construction, resource leak occurs".

I disagree with this assessment, though; the real problem is that their ComplexClass constructor body is not exception-safe. With that in place, the code will be far more robust with simple RAII, especially as it scales.

In terms of "why did they not simply require scoped_ptr": I'd imagine it's a C++03 document that's talking about C++, not third party libraries.

这篇关于为什么没有bada需要scoped_ptr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆