Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

NoPtr Namespace Reference


Detailed Description

Namespace in which every class/function of the NoPtr library is defined.

Author:
Oliver Schoenborn


Compounds

class  DynObj
 Class DynObj<TT> is a proxy for a Dynamically Allocated Object (DAO -- i.e., an object created via a call to new) of type TT. More...

class  DynTmp
 A DynTmp represents an unnamed temporary DynObj. More...

class  RRef
 This class represents a reference to another object, of type DynObj or subclass of RRefable. More...

class  RRefable
 Derive from this class to make your subclass a RRef'able object. More...


Typedefs

typedef NoPtrImpl::InValueContainer<
NoPtrImpl::RefCount > 
InValueContainer
 Specify the InValueContainer type as second template parameter to DynObj to be able to use DynObj inside a value-based container, such as an STL container.

typedef NoPtrImpl::InValueContainer<
NoPtrImpl::ChainNode > 
InValueContainerOpt1
 Specify the InValueContainerOpt1 instead of InValueContainer context implementation for slightly better performance than the latter.

typedef NoPtrImpl::InValueContainer<
NoPtrImpl::SegmentNode > 
InValueContainerOpt2
 Specify the InValueContainerOpt2 instead of InValueContainerOpt1 context implementation for slightly better performance than the latter.


Functions

template<typename TT, class Context> bool isNull (const DynObj< TT, Context > &p)
 Overload of isNull(TT*) for DynObj types; it just calls DynObj::isNull.

template<typename TT, class Context> bool isNotNull (const DynObj< TT, Context > &p)
 Overload of isNotNull(TT*) for DynObj types; it just calls DynObj::isNotNull.

template<typename ObjType> DynTmp< ObjType > makeDynTmp (ObjType *const newDAO)
 Helper function to create a DynTmp of a type deduced from the argument.

template<typename ObjType> DynTmp< ObjType > makeDynObj (ObjType *const newDAO)
 Helper function that does the same thing as makeDynTmp, but may present a more meaningful name when inserting a DAO into a container of DynObj's.

template<typename T> bool isNull (T *p)
 Test if a pointer is null.

template<typename T> bool isNotNull (T *p)
 Test if a pointer is not null.

template<typename T> void nullify (T *&p)
 Set a pointer to null.

template<typename TT> bool isNull (const RRef< TT > &p)
 Overload of isNull(TT*) for RRef types; it just calls RRef::isNull.

template<typename TT> bool isNotNull (const RRef< TT > &p)
 Overload of isNotNull(TT*) for RRef types; it just calls RRef::isNotNull.


Variables

const int NullPtr = 0
 Replace NULL with a non-macro. Use this instead of NULL.


Typedef Documentation

typedef NoPtrImpl::InValueContainer<NoPtrImpl::RefCount> NoPtr::InValueContainer
 

Specify the InValueContainer type as second template parameter to DynObj to be able to use DynObj inside a value-based container, such as an STL container.

See DynObj for more info. Note that this implementation of the value-container context can never fail.

Definition at line 55 of file NoPtrFwd.hh.

typedef NoPtrImpl::InValueContainer<NoPtrImpl::ChainNode> NoPtr::InValueContainerOpt1
 

Specify the InValueContainerOpt1 instead of InValueContainer context implementation for slightly better performance than the latter.

This could fail due to run-time assertion but would be extremely rare. If this happens you have no choice but to stick with InValueContainer.

Definition at line 63 of file NoPtrFwd.hh.

typedef NoPtrImpl::InValueContainer<NoPtrImpl::SegmentNode> NoPtr::InValueContainerOpt2
 

Specify the InValueContainerOpt2 instead of InValueContainerOpt1 context implementation for slightly better performance than the latter.

This could fail due to run-time assertion but would be extremely rare. If this happens you may have to stick with InValueContainerOpt1 (and if that one begets a failed assertion, you have no choice but to stick with InValueContainer).

Definition at line 72 of file NoPtrFwd.hh.


Function Documentation

template<typename ObjType>
DynTmp<ObjType> makeDynTmp ObjType *const  newDAO  ) 
 

Helper function to create a DynTmp of a type deduced from the argument.

Useful when giving a new DAO to a container of DynObj, e.g.

        std::vector<DynObj<Foo>::InValueContainer> vec;
        vec.push_back(makeDynTmp(new Foo));
        vec.push_back(DynTmp<Foo>(new Foo)); // same but longer

Definition at line 125 of file DynTmp.hh.

template<typename ObjType>
DynTmp<ObjType> makeDynObj ObjType *const  newDAO  ) 
 

Helper function that does the same thing as makeDynTmp, but may present a more meaningful name when inserting a DAO into a container of DynObj's.

This is necessary because creating a DynObj from a pointer can only be done explicitly (not implicitly), yet a DynObj<T>::InValueContainer can't be explicitly instantiated. Hence this helper function, which is shorter than the form that uses DynTmp and more meaningful than the one using makeDynTmp:

        std::list<DynObj<T>::InValueContainer> list;
        list.push_back( makeDynObj(new T) );

Definition at line 141 of file DynTmp.hh.

template<typename T>
bool isNull T *  p  )  [inline]
 

Test if a pointer is null.

Use this instead of comparing to NULL.

Returns:
true if pointer == 0.

Definition at line 34 of file nullness.hh.

template<typename T>
bool isNotNull T *  p  )  [inline]
 

Test if a pointer is not null.

Use this instead of comparing to NULL.

Returns:
true if pointer != 0.

Definition at line 42 of file nullness.hh.

template<typename T>
void nullify T *&  p  )  [inline]
 

Set a pointer to null.

Use this instead of ptr=0 since clearer that ptr is a pointer rather than an integer, plus it is greppable.

Parameters:
p the pointer to nullify

Definition at line 51 of file nullness.hh.


Generated on Mon Aug 4 18:51:33 2003 for NoPtr C++ Library by doxygen 1.3.2