Search code examples
c++bada

Why didn't bada require scoped_ptr?


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?


Solution

  • 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.