typed_factory< T > Class Template Reference
[toast miscellaneous utilities]

#include <toast/typed_factory.hpp>

List of all members.


Detailed Description

template<typename T>
class typed_factory< T >

An object that holds arguments for deferred object creation.

A typed_factory holds copies of arguments that can later be used to construct an object of the specified type. typed_factory derives from boost::typed_in_place_factory so it can be used to initialize a boost::optional for a type that is non-copyable.

This class exists for two reasons:

1. boost's typed factory forces you to pass by reference. With toast::typed_factory you can use boost::ref instead.

2. boost's typed factory pre-boost-1.35 was missing a nullary version.

For examples of use, see unintrusive_ptr's unit test. Although not listed above (because Doxygen doesn't interact well with Boost's preprocessor library), typed_factory has constructors of up to TOAST_MAX_TYPED_FACTORY_ARITY arity. You can define TOAST_MAX_TYPED_FACTORY_ARITY yourself to set the maximum value, otherwise it will default to 10.

Public Types

typedef T value_type

Public Member Functions

T * create () const
void apply (void *addr) const


Member Function Documentation

template<typename T>
T* typed_factory< T >::create (  )  const [inline]

Return a new object using the factory function that the user is responsible for managing

template<typename T>
void typed_factory< T >::apply ( void *  addr  )  const [inline]

Initialize the given address with the factory function. The address must have been allocated by the user prior to calling apply and be large enough to hold T.


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

SourceForge.net Logo