Bromeon
Classes | Functions
SmartPtr

Provides smart pointers with different ownership strategies. More...

Classes

class  thor::CopiedPtr< T, OwnershipPolicy >
 Generic smart pointer class that supports several deep copy ownership policies. More...
class  thor::MovedPtr< T, OwnershipPolicy >
 Smart pointer with move semantics. More...
struct  thor::NoCopy< T >
 Ownership policy that performs no copy. More...
struct  thor::StaticCopy< T >
 Ownership policy that performs a deep value copy. More...
struct  thor::DynamicCopy< T >
 Ownership policy that performs a deep copy depending on the object's dynamic type. More...
struct  thor::VirtualClone< T >
 Ownership policy that calls a virtual Clone() function. More...
class  thor::ScopedPtr< T >
 Noncopyable smart pointer that destroys objects going out of scope. More...

Functions

template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > thor::Move (CopiedPtr< T, OwnershipPolicy > &source)
 Creates a MovedPtr from a CopiedPtr by moving ownership.
template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > thor::Copy (const CopiedPtr< T, OwnershipPolicy > &origin)
 Creates a MovedPtr from a CopiedPtr by copying ownership.
template<typename T , template< typename > class OwnershipPolicy>
void thor::swap (CopiedPtr< T, OwnershipPolicy > &lhs, CopiedPtr< T, OwnershipPolicy > &rhs)
 Swaps two CopiedPtr<T, OwnershipPolicy> instances.
template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > thor::Copy (const MovedPtr< T, OwnershipPolicy > &origin)
 Creates a MovedPtr from another MovedPtr by copying ownership.
template<typename T , template< typename > class OwnershipPolicy>
void thor::swap (MovedPtr< T, OwnershipPolicy > &lhs, MovedPtr< T, OwnershipPolicy > &rhs)
 Swaps two MovedPtr<T, OwnershipPolicy> instances.
template<typename T >
void thor::swap (ScopedPtr< T > &lhs, ScopedPtr< T > &rhs)
 Swaps two ScopedPtr<T> instances.

Detailed Description

Provides smart pointers with different ownership strategies.


Function Documentation

template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > Copy ( const MovedPtr< T, OwnershipPolicy > &  origin) [related]

Creates a MovedPtr from another MovedPtr by copying ownership.

Parameters:
originThe original smart pointer whose ownership is copied.
Returns:
MovedPtr acting as carrier for the copied object. The returned smart pointer contains a copy of origin.
  thor::MovedPtr<MyClass, thor::StaticCopy> a(new MyClass);
  thor::MovedPtr<MyClass, thor::StaticCopy> b = thor::Copy(a);
  // a is unchanged, b has a copy of a's object.
template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > Copy ( const CopiedPtr< T, OwnershipPolicy > &  origin) [related]

Creates a MovedPtr from a CopiedPtr by copying ownership.

Parameters:
originThe original smart pointer whose ownership is copied.
Returns:
MovedPtr acting as carrier for the copied object. The returned smart pointer contains a copy of origin.
  thor::CopiedPtr<MyClass, thor::StaticCopy> a(new MyClass);
  thor::MovedPtr<MyClass, thor::StaticCopy> b = thor::Copy(a);
  // a is unchanged, b has a copy of a's object.
template<typename T , template< typename > class OwnershipPolicy>
MovedPtr< T, OwnershipPolicy > Move ( CopiedPtr< T, OwnershipPolicy > &  source) [related]

Creates a MovedPtr from a CopiedPtr by moving ownership.

Parameters:
sourceThe original smart pointer which loses ownership.
Returns:
MovedPtr acting as carrier for the transferred object. You can assign it to another CopiedPtr to transfer ownership without copying the owned object:
  thor::CopiedPtr<MyClass, thor::StaticCopy> a(new MyClass);
  thor::CopiedPtr<MyClass, thor::StaticCopy> b = thor::Move(a);
  // a is now empty, b has its object, no copy occurred.