# bdm::object_ptr< T > Class Template Reference

A wrapper of shared_ptr which is never empty. More...

## Detailed Description

### template<typename T>
class bdm::object_ptr< T >

A wrapper of shared_ptr which is never empty.

T must have a default constructor.

Note that shared_ptr's destructor isn't virtual - don't call delete on pointers to instances of this class.

`#include <shared_ptr.h>`

List of all members.

## Public Member Functions
| object_ptr ()
| Default constructor.
| object_ptr (const shared_ptr< T > &b)
| Upcast from shared_ptr<T> to object_ptr<T>.
| object_ptr (T *p)
object_ptr< T > & | operator= (const object_ptr< T > &other)
| Assignment operator.
T * | get ()
const T * | get () const
T * | operator-> ()
const T * | operator-> () const
T & | operator* ()
const T & | operator* () const
bool | unique () const
| Returns use_count() == 1.
long | use_count () const
| operator bool () const
| Boolean cast.
template<typename U >
| operator shared_ptr< const U > () const
| const cast
void | swap (shared_ptr &other)
| Efficient swap for shared_ptr.

## Constructor & Destructor Documentation

template<typename T>

bdm::object_ptr< T >::object_ptr | ( |  | ) | `[inline]`

Default constructor.

Calls T's default constructor.

template<typename T>

bdm::object_ptr< T >::object_ptr | ( | const shared_ptr< T > & | b | ) | `[inline]`

Upcast from shared_ptr<T> to object_ptr<T>.

Parameters:

  | b | The shared pointer, which must not be empty.

References bdm_assert_debug.

template<typename T>

bdm::object_ptr< T >::object_ptr | ( | T * | p | ) | `[inline]`

Constructs an object_ptr that owns the pointer p. p must have been alllocated by new!

References bdm_assert_debug.

## Member Function Documentation

template<typename T>

const T* bdm::shared_ptr< T >::get | ( |  | ) | const`[inline, inherited]`

Returns the stored pointer (which remains owned by this instance). For empty instances, this method returns NULL.

template<typename T>

T* bdm::shared_ptr< T >::get | ( |  | ) | `[inline, inherited]`

Returns the stored pointer (which remains owned by this instance). For empty instances, this method returns NULL.

Referenced by bdm::mepdf::from_setting(), bdm::mepdf::mepdf(), and bdm::Kalman< fsqmat >::posterior().

template<typename T>

bdm::shared_ptr< T >::operator bool | ( |  | ) | const`[inline, inherited]`

Boolean cast.

This operator returns true if and only if the instance isn't empty.

template<typename T>
template<typename U >

bdm::shared_ptr< T >::operator shared_ptr< const U > | ( |  | ) | const`[inline, inherited]`

const cast

Shared pointer to T can be converted to shared pointer to const T, just like T * can be converted to T const *.

template<typename T>

const T& bdm::shared_ptr< T >::operator* | ( |  | ) | const`[inline, inherited]`

Returns a reference to the object pointed to by the stored pointer. This method may only be called when the stored pointer isn't NULL.

template<typename T>

T& bdm::shared_ptr< T >::operator* | ( |  | ) | `[inline, inherited]`

Returns a reference to the object pointed to by the stored pointer. This method may only be called when the stored pointer isn't NULL.

template<typename T>

const T* bdm::shared_ptr< T >::operator-> | ( |  | ) | const`[inline, inherited]`

Returns the stored pointer (which remains owned by this instance). This method may only be called when the stored pointer isn't NULL.

template<typename T>

T* bdm::shared_ptr< T >::operator-> | ( |  | ) | `[inline, inherited]`

Dereferences the stored pointer (which remains owned by this instance). This method may only be called when the stored pointer isn't NULL.

template<typename T>

long bdm::shared_ptr< T >::use_count | ( |  | ) | const`[inline, inherited]`

Returns the number of shared_ptr instances (including this instance) that share ownership with this instance. For empty instances, this method returns 0.

The documentation for this class was generated from the following file:

- shared_ptr.h