Smart Pointers

allocator_default_policy Struct Reference

#include <smart_ptr.hpp>

List of all members.


Detailed Description

This is the Default allocator policy for smart_ptr. This policy does NOT require that the target class have a clone function or clone logic. Cloning is performed by using the type pass to the constructor. In order to use this policy, the target type must be pass to the constructor.
Example Usage.

void example_allocator_policy_usage()
{
        smart_ptr<ShapeWithNoCloneLogic, ownership_default_policy, allocator_default_policy> vShape1(new CircleWithNoCloneLogic);
        smart_ptr<ShapeWithNoCloneLogic, ownership_default_policy, allocator_default_policy> vShape2(vShape1);
        std::cout << vShape2->GetTypeName() << std::cout;
}

Note:
This policy can detect slicing better than the clone_function_allocator_policy, but not as well as the clone_static_function_allocator_policy. allocator_default_policy can detect slicing at runtime through constructor. This policy is more generic than clone_function_allocator_policy and clone_static_function_allocator_policy, because it does not require the target class to have any type of clone function.
See also:
smart_ptr, clone_function_allocator_policy, clone_static_function_allocator_policy

Definition at line 123 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 the type copy constructor.
template<typename T_obj>
static void deallocate (T_obj *ptr)


Member Function Documentation

static T_obj* allocate const T_obj *  ptr  )  [inline, static]
 

allocate clones the input argument by calling the type copy constructor.

Precondition:
Requires type to have a copy constructor, and pointee to be same type as pointer
Warning:
warning.gif Requires correct type for proper cloning
Parameters:
[in] ptr valid pointer or NULL
Returns:
A new object, or NULL if input parameter is NULL

Definition at line 134 of file smart_ptr.hpp.

static void deallocate T_obj *  ptr  )  [inline, static]
 

Parameters:
[in] ptr valid pointer or NULL

Definition at line 142 of file smart_ptr.hpp.


The documentation for this struct was generated from the following file:
Generated on Wed Mar 29 21:58:59 2006 for Smart Pointers by  doxygen 1.4.6.Axter [Axter-Extended-Version]