Memory management
In CppUnit 1, it was difficult to know when passing a parameter what its expected life was and who was responsible to delete it.
CppUnit2 solves this by using smart-pointer for dynamically allocated objects, and the following conventions:
- pass by smart-pointer when the ownership of the parameter is transfered/shared.
- pass by const reference indicates a 'pass by value', the parameter will be copied if needed.
- pass by non const reference indicates that the ownership will not be assumed. The life-cycle requirement depends on the semantic of the function. In most case, if it is a constructor, then the reference is expected to be valid as long as the object being constructed.
The use of smart-pointer has greatly simplified the overall implementation (especially the TestFactoryRegistry).
CppUnit2 comes with its own smart-pointer, which implements a subset of the generic smart-pointer that has been adopted by the standard C++ committee (neither weak pointer, nor checked_deleter are supported).
A standard conformant implementation (boost:shared_ptr) can be used if CPPUT_USE_BOOST_SHARED_PTR is defined.