|
#include <smart_ptr.hpp>
struct ShapeWithVirtualCloneLogic { ShapeWithVirtualCloneLogic(){} ~ShapeWithVirtualCloneLogic(){} ShapeWithVirtualCloneLogic(const ShapeWithVirtualCloneLogic& src){} virtual std::string GetTypeName()const = 0; virtual ShapeWithVirtualCloneLogic* do_clone()const=0; //Needed for clone_function_allocator_policy }; struct CircleWithVirtualCloneLogic : public ShapeWithVirtualCloneLogic { CircleWithVirtualCloneLogic(){} ~CircleWithVirtualCloneLogic(){} CircleWithVirtualCloneLogic(const CircleWithVirtualCloneLogic& src){} std::string GetTypeName()const{return "Circle";} ShapeWithVirtualCloneLogic* do_clone()const{return new CircleWithVirtualCloneLogic(*this);}//Needed for clone_function_allocator_policy }; void example_clone_function_allocator_policy_usage() { smart_ptr<ShapeWithVirtualCloneLogic, ownership_default_policy, clone_function_allocator_policy> vShape1(new CircleWithVirtualCloneLogic); smart_ptr<ShapeWithVirtualCloneLogic, ownership_default_policy, clone_function_allocator_policy> vShape2(vShape1); std::cout << vShape2->GetTypeName() << std::cout; }
Definition at line 165 of file smart_ptr.hpp.
Static Public Member Functions | |
template<typename T_obj> | |
static T_obj * | allocate (const T_obj *ptr) |
allocate clones the input argument by calling virtual function do_clone. | |
template<typename T_obj> | |
static void | deallocate (T_obj *ptr) |
|
allocate clones the input argument by calling virtual function do_clone.
Definition at line 176 of file smart_ptr.hpp. |
|
Definition at line 184 of file smart_ptr.hpp. |