From 3118946989984b3d1bd4a14cb1849f49ac8d7abc Mon Sep 17 00:00:00 2001
From: Steven Watanabe Copyright © 2007, 2008 Tobias Schwinger Copyright © 2007, 2008 Tobias Schwinger
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
The template
In traditional Object Oriented Programming a Factory is an object implementing
an interface of one or more methods that construct objects conforming to known
@@ -112,7 +114,7 @@
// [...]
- std::auto_ptr<an_abstract_factory> x = factories[some_name]->create();
+ std::auto_ptr<an_abstract_class> x(factories.at(some_name).create());
// [...]
}
@@ -130,7 +132,7 @@
objects,
o we might not necessarily need a polymorphic base class for the objects,
o as we will see, we do not need a factory base class at all,
-o we might want to just call the constructor - without #new# to create
+o we might want to just call the constructor - without `new` to create
an object on the stack, and
o finally we might want to use customized memory management.
@@ -246,33 +248,35 @@
Smart Pointers.
Function object template that invokes the constructor of the type
- an arbitrary type with at least one public constructor
-
@@ -17,16 +17,16 @@
-boost::factory
lets you encapsulate a new
expression as a function object, boost::value_factory
encapsulates a constructor invocation without new
.
@@ -61,9 +62,10 @@
or boost::bind
.
+
+ Description
+
T
.
-
- Header
-
+
+
+ Header
+
#include <boost/functional/value_factory.hpp>
-
-
- Synopsis
-
+
+
+ Synopsis
+
namespace boost
{
template< typename T >
@@ -284,27 +288,27 @@
T
a0
...aN
- argument LValues to a constructor of T
-
T
+
F
- the type value_factory<F>
-
value_factory<F>
+
f
- an instance object of F
-
F
+
-
- - Expression - ++ Expression + |
- - Semantics - ++ Semantics + |
---|---|
-
-
+ |
-
- creates an object of type
+ creates an object of type |
-
-
+ |
-
- creates an object of type
+ creates an object of type |
-
-
+ |
-
- returns
+ returns |
-
-
+ |
-
- is the type
+ is the type |
The macro BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY can be defined to set the maximum arity. It defaults to 10.
-Function object template that dynamically constructs a pointee object for the type of pointer given as template argument. Smart pointers may be used @@ -396,12 +401,12 @@ yields the pointee type.
- If an _allocator_ is given, it is used
+ If an _allocator_ is given, it is used
for memory allocation and the placement form of the new
operator is used to construct the object. A function object that calls the
destructor and deallocates the memory with a copy of the Allocator is used
for the second constructor argument of Pointer
- (thus it must be a __smartpointer_
+ (thus it must be a _smart_pointer_
that provides a suitable constructor, such as boost::shared_ptr
).
@@ -409,16 +414,16 @@
the allocator itself is used for the third constructor argument of Pointer
(boost::shared_ptr
then uses the allocator
to manage the memory of its seperately allocated reference counter).
#include <boost/functional/factory.hpp>-
namespace boost { enum factory_alloc_propagation @@ -439,31 +444,31 @@
T
- an arbitrary type with at least one public constructor -
P
- pointer or smart pointer to T
-
T
+
a0
...aN
- argument LValues to a constructor of T
-
T
+
F
- the type factory<P>
-
factory<P>
+
f
- an instance object of F
-
F
+
- - Expression - ++ Expression + |
- - Semantics - ++ Semantics + |
---|---|
-
-
+ |
-
- creates an object of type
+ creates an object of type |
-
-
+ |
-
- creates an object of type
+ creates an object of type |
-
-
+ |
-
- dynamically creates an object of type
+ dynamically creates an object of type |
-
-
+ |
-
- is the type
+ is the type |
The macro BOOST_FUNCTIONAL_FACTORY_MAX_ARITY can be defined to set the maximum arity. It defaults to 10.
-Eric Niebler requested a function to invoke a type's constructor (with the arguments supplied as a Tuple) as a Fusion feature. These Factory utilities @@ -565,26 +571,27 @@ and their evolution.
-