Smart Pointers

Smart Pointers Class List

Here are the classes, structs, unions and interfaces with brief descriptions:
allocator_default_policyThis 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
clone_function_allocator_policyThis is an allocator policy that uses traditional cloning method. This policy requires that the target class have a virtual clone function. The normal usage is to create a base class with a pure virtual clone function, and have each derived class implement the clone function. This includes derived derived classes, and so-on.
Example Usage
clone_static_function_allocator_policyThis is an allocator policy that uses a static cloning method. This policy requires that the target class have a static clone function. Each derived class must implement the static clone function. This includes derived derived classes, and so-on.
Example Usage
copy_on_write_policyThis is a copy on write ownership policy. This policy is a mixture of a deep copy clone policy and the shared pointer policy. It shares the pointer as long as no attempt is made to access the pointee through non-constant operator->().
When access is made to the non-constant operator->(), the smart pointer clones itself if it's being referenced. When it clones itself, it performs a deep copy of the pointee.
Example Usage
copy_ptrCopy_ptr is a deep copy (Clone) smart pointer that does not require the pointee to have clone function logic
cow_ptrCow_ptr is a Copy On Write smart pointer. It does not require the pointee to have clone function logic
deep_copy_policyThis is a deep copy (Clone) ownership policy. This policy is similar to most clone smart pointers. However, when use with default allocator policy, this type of policy does NOT require that the pointee have a clone function implementation.
Example Usage
intrusive_lock_policyThis implements an intrusive lock policy. Allows synchronization of the smart pointer and the pointee.
The intrusive_lock_policy requires the user to implement two intrusive lock functions that take the pointer type.
void intrusive_ptr_lock(T * p);
void intrusive_ptr_unlock(T * p);
Where T is the target type, and the functions are in a namespace accessible to the lock policy.
Optionally, the following functions can also be implemented, but are not required:
bool intrusive_ptr_trylock(T * p); bool intrusive_ptr_islock(T * p);
Example Usage
mutex_wrapperMutex_wrapper is a class that implements intrusive lock functions for target type. In order to use the intrusive_lock_policy, the target type requires two intrusive lock functions.
void intrusive_ptr_lock(T * p);
void intrusive_ptr_unlock(T * p);
Moreover, the target type also needs to store lock handle(s) and/or lock state. The mutex_wrapper class can be used to automatically add the required lock implementation to the target type, and therefore allow for the use of a synchronized smart pointer on any type.
Example Usage
no_checking_policyNo_checking_policy has all checking functions stubbed out, and performs no checking
no_comparsion_semantic_policyThis prevents comparison operators from being used with the smart_ptr. Use this policy to disallow the use of comparison operators
no_lock_policyThe no lock policy has no lock implementation. Use this policy when synchronization is not required.
no_stream_operator_semantic_policyThis is a policy that prevents usage of stream operator. Use this policy so as to disallow stream operator usage with the smart pointer

no_weak_support
pointer_comparsion_semantic_policyThis makes smart_ptr compare the pointer address. This policy gives the smart_ptr class normal pointer semantics when use with comparison operators. Comparison operators compare pointer address instead of pointee object. This may be desirable when using generic smart pointer coding, in which smart_ptr needs to work the same as other smart pointers
ref_count_policyUse this policy to create a reference counting smart pointer. This policy is similar to reference counting logic used by boost::shared_ptr. In general, it is slower than the other two reference policies (ref_link_policy and ref_intrusive_policy). It is more generic than ref_intrusive_policy, since it does not require that the target type have intrusive functions. It takes less space than ref_link_policy, and it's easier to implement in synchronized code, than ref_link_policy. Use this policy when space is the primary factor, or when referencing the same object in multiple threads and you don't wish to use an intrusive_lock_policy.
Example Usage
ref_intrusive_policyUse this policy to create an intrusive reference smart pointer. In general, this policy is faster than both ref_count_policy and ref_link_policy. However, it requires three intrusive functions that take the target type pointer as a parameter.
void intrusive_ptr_add_ref(T *);
void intrusive_ptr_release(T *);
bool intrusive_ptr_is_ref(T *);
Example implementation for intrusive functions:
void intrusive_ptr_add_ref(Shape * p){++(p->references);}
void intrusive_ptr_release(Shape * p){
if (--(p->references) == 0)
delete p;
}
bool intrusive_ptr_is_ref(Shape * p){return (p->references > 1);}

Example Usage
ref_link_policyUse this policy to create a reference linking smart pointer. In general, this policy is faster than the ref_count_policy, but takes a little more memory. It's not as easy to implement in synchronized code compare to ref_count_policy. It is more generic than ref_intrusive_policy, since it does not require that the target type have intrusive functions. Use ref_link_policy, when speed is the primary factor, there is no synchronized referencing requirements, and there's no desire to implement intrusive functions on the target type.
Example Usage
scope_lockThe scope_lock can be used with lock policy to lock a pointer within a scope.
Example Usage
shared_ptr_policyThis is a shared pointer ownership policy. This policy is similar to the ownership policy used by boost::shared_ptr. However, by default, the shared_ptr_policy uses reference link instead of reference counting logic that is used by boost::shared_ptr. In general, reference link logic is faster than reference counting, so this make shared_ptr_policy with it's default policies faster in general than boost::shared_ptr. For more information on pros and cons of the different reference logic available, see ref_link_policy, ref_count_policy, and ref_intrusive_policy.
Example Usage
smart_ptrSmart_ptr is a smart pointer policy class that can use different ownership logic and semantic polices, which allows the developer to get the best performance and/or interface for a particular requirement
smart_ptr_baseSmart_ptr_base is the base class for smart_ptr. The main purpose for the smart_ptr_base is to make smart_ptr exception safe. When an exception is thrown, only objects that have been constructed gets their destructor's called. A base class gets constructed before the derived class members. If the base class gets constructed, and a the derived class member throws an exception, the base class destructor is guaranteed to be called. If no exception is thrown, than the base class destructor does nothing, because smart_ptr will nullify the pointer in it's destructor. This insures that a memory leak does not occur if smart_ptr's members throw an exception in their constructor
sync_ctrlSync_ctrl is an interface class used by sync_ptr. This interface class is used to separate implementation lock details from the sync_ptr class
sync_ptrSync_ptr is a portable synchronized smart pointer
sync_ptr::RefLockPtrRefLockPtr is a helper class used by sync_ptr to perform an automatic lock when operator->() is called
sync_ref_ptrSync_ref_ptr is a synchronized reference counting smart pointer
value_arithmetic_semantic_policyThis is a policy to allow arithmetic operators to target the pointee. Use this policy to allow arithmetic operators to target the pointee instead of the pointer. Normally, smart pointers try to emulate raw pointers, and when arithmetic operations are performed using the pointer, instead of what the pointer is pointing to. This policy allows arithmetic operators to perform operations on the pointee, instead of the pointer.
Example Usage
value_comparsion_semantic_policyThis makes smart_ptr compare the pointee instead of the pointer address. This is a policy that allows smart_ptr to be used with associated containers, and STL sorting algorithms. When used with comparison operators, this policy makes smart_ptr compare the pointee, instead of the pointer address.
Example Usage
value_stream_operator_semantic_policyThis is a pointee stream operator semantic policy. Use this policy so as to allow stream operators to operate on the pointee
Example Usage
weak_storage
weak_storage::ref_count

Generated on Wed Mar 29 21:58:59 2006 for Smart Pointers by  doxygen 1.4.6.Axter [Axter-Extended-Version]