Fully merge all of functional (including sublibs).

Should be just documentation and metadata changes. There might be a problem
witht he generated documentation for overloaded_function, if so I'll fix it
very soon.


[SVN r84625]
This commit is contained in:
Daniel James
2013-06-03 22:13:57 +00:00
parent eebb4df856
commit b271abdda3
14 changed files with 114 additions and 2298 deletions

View File

@@ -23,15 +23,17 @@
[def __boost_function__ [@http://www.boost.org/doc/html/function.html Boost.Function]]
[def __boost__function__ [@http://www.boost.org/doc/html/function.html `boost::function`]]
[def __smart_pointer__ [@http://www.boost.org/libs/smart_ptr/index.html Smart Pointer]]
[def __smart_pointers__ [@http://www.boost.org/libs/smart_ptr/index.html Smart Pointers]]
[def __boost__shared_ptr__ [@http://www.boost.org/libs/smart_ptr/shared_ptr.htm `boost::shared_ptr`]]
[def __std__map__ [@http://www.sgi.com/tech/stl/map.html `std::map`]]
[def __std__string__ [@http://www.sgi.com/tech/stl/string.html `std::string`]]
[def __allocator__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocator]]
[def __std_allocator__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocator]]
[def __std_allocators__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocators]]
[def __boost__ptr_map__ [@http://www.boost.org/libs/ptr_container/doc/ptr_map.html `__boost__ptr_map__`]]
[def __boost__ptr_map__ [@http://www.boost.org/libs/ptr_container/doc/ptr_map.html `boost::ptr_map`]]
[def __boost__factory__ `boost::factory`]
[def __boost__value_factory__ `boost::value_factory`]
@@ -107,7 +109,7 @@ interfaces.
// [...]
std::auto_ptr<an_abstract_factory> x = factories[some_name]->create();
std::auto_ptr<an_abstract_class> x(factories.at(some_name).create());
// [...]
}
@@ -117,30 +119,30 @@ lots of boilerplate code. In other words there is too much code to express
a rather simple intention. We could use templates to get rid of some of it
but the approach remains inflexible:
o We may want a factory that takes some arguments that are forwarded to
the constructor,
o we will probably want to use smart pointers,
o we may want several member functions to create different kinds of
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
an object on the stack, and
o finally we might want to use customized memory management.
* We may want a factory that takes some arguments that are forwarded to
the constructor,
* we will probably want to use smart pointers,
* we may want several member functions to create different kinds of
objects,
* we might not necessarily need a polymorphic base class for the objects,
* as we will see, we do not need a factory base class at all,
* we might want to just call the constructor - without `new` to create
an object on the stack, and
* finally we might want to use customized memory management.
Experience has shown that using function objects and generic Boost components
for their composition, Design Patterns that describe callback mechasisms
for their composition, Design Patterns that describe callback mechanisms
(typically requiring a high percentage of boilerplate code with pure Object
Oriented methodology) become implementable with just few code lines and without
extra classes.
Factories are callback mechanisms for constructors, so we provide two class
templates, __boost__value_factory__ and __boost__factory__, that encasulate
templates, __boost__value_factory__ and __boost__factory__, that encapsulate
object construction via direct application of the constructor and the `new`
operator, respectively.
We let the function objects forward their arguments to the construction
expressions they encapsulate. Overthis __boost__factory__ optionally allows
expressions they encapsulate. Over this __boost__factory__ optionally allows
the use of smart pointers and __std_allocators__.
Compile-time polymorphism can be used where appropriate,
@@ -156,7 +158,7 @@ Compile-time polymorphism can be used where appropriate,
// [...]
}
Now, to allow inhomogenous signaturs for the constructors of the types passed
Now, to allow inhomogeneous signatures for the constructors of the types passed
in for `T` we can use __value_factory__ and __boost__bind__ to normalize between
them.
@@ -299,7 +301,7 @@ constructor, such as __boost__shared_ptr__).
If a third template argument is `factory_passes_alloc_to_smart_pointer`,
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).
separately allocated reference counter).
[heading Header]
#include <boost/functional/factory.hpp>

View File

@@ -1,528 +0,0 @@
/*=============================================================================
Copyright (c) 2004 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to 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)
=============================================================================*/
/*=============================================================================
Body defaults
=============================================================================*/
body
{
margin: 1em;
font-family: sans-serif;
}
/*=============================================================================
Paragraphs
=============================================================================*/
p
{
text-align: left;
font-size: 10pt;
line-height: 1.15;
}
/*=============================================================================
Program listings
=============================================================================*/
/* Code on paragraphs */
p tt.computeroutput
{
font-size: 9pt;
}
pre.synopsis
{
font-size: 90%;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
.programlisting,
.screen
{
font-size: 9pt;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
/* Program listings in tables don't get borders */
td .programlisting,
td .screen
{
margin: 0pc 0pc 0pc 0pc;
padding: 0pc 0pc 0pc 0pc;
}
/*=============================================================================
Headings
=============================================================================*/
h1, h2, h3, h4, h5, h6
{
text-align: left;
margin: 1em 0em 0.5em 0em;
font-weight: bold;
}
h1 { font: 140% }
h2 { font: bold 140% }
h3 { font: bold 130% }
h4 { font: bold 120% }
h5 { font: italic 110% }
h6 { font: italic 100% }
/* Top page titles */
title,
h1.title,
h2.title
h3.title,
h4.title,
h5.title,
h6.title,
.refentrytitle
{
font-weight: bold;
margin-bottom: 1pc;
}
h1.title { font-size: 140% }
h2.title { font-size: 140% }
h3.title { font-size: 130% }
h4.title { font-size: 120% }
h5.title { font-size: 110% }
h6.title { font-size: 100% }
.section h1
{
margin: 0em 0em 0.5em 0em;
font-size: 140%;
}
.section h2 { font-size: 140% }
.section h3 { font-size: 130% }
.section h4 { font-size: 120% }
.section h5 { font-size: 110% }
.section h6 { font-size: 100% }
/* Code on titles */
h1 tt.computeroutput { font-size: 140% }
h2 tt.computeroutput { font-size: 140% }
h3 tt.computeroutput { font-size: 130% }
h4 tt.computeroutput { font-size: 120% }
h5 tt.computeroutput { font-size: 110% }
h6 tt.computeroutput { font-size: 100% }
/*=============================================================================
Author
=============================================================================*/
h3.author
{
font-size: 100%
}
/*=============================================================================
Lists
=============================================================================*/
li
{
font-size: 10pt;
line-height: 1.3;
}
/* Unordered lists */
ul
{
text-align: left;
}
/* Ordered lists */
ol
{
text-align: left;
}
/*=============================================================================
Links
=============================================================================*/
a
{
text-decoration: none; /* no underline */
}
a:hover
{
text-decoration: underline;
}
/*=============================================================================
Spirit style navigation
=============================================================================*/
.spirit-nav
{
text-align: right;
}
.spirit-nav a
{
color: white;
padding-left: 0.5em;
}
.spirit-nav img
{
border-width: 0px;
}
/*=============================================================================
Table of contents
=============================================================================*/
.toc
{
margin: 1pc 4% 0pc 4%;
padding: 0.1pc 1pc 0.1pc 1pc;
font-size: 80%;
line-height: 1.15;
}
.boost-toc
{
float: right;
padding: 0.5pc;
}
/*=============================================================================
Tables
=============================================================================*/
.table-title,
div.table p.title
{
margin-left: 4%;
padding-right: 0.5em;
padding-left: 0.5em;
}
.informaltable table,
.table table
{
width: 92%;
margin-left: 4%;
margin-right: 4%;
}
div.informaltable table,
div.table table
{
padding: 4px;
}
/* Table Cells */
div.informaltable table tr td,
div.table table tr td
{
padding: 0.5em;
text-align: left;
font-size: 9pt;
}
div.informaltable table tr th,
div.table table tr th
{
padding: 0.5em 0.5em 0.5em 0.5em;
border: 1pt solid white;
font-size: 80%;
}
/*=============================================================================
Blurbs
=============================================================================*/
div.note,
div.tip,
div.important,
div.caution,
div.warning,
div.sidebar
{
font-size: 9pt; /* A little bit smaller than the main text */
line-height: 1.2;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.0pc 0.5pc;
}
div.sidebar img
{
padding: 1pt;
}
/*=============================================================================
Callouts
=============================================================================*/
.line_callout_bug img
{
float: left;
position:relative;
left: 4px;
top: -12px;
clear: left;
margin-left:-22px;
}
.callout_bug img
{
}
/*=============================================================================
Variable Lists
=============================================================================*/
/* Make the terms in definition lists bold */
div.variablelist dl dt,
span.term
{
font-weight: bold;
font-size: 10pt;
}
div.variablelist table tbody tr td
{
text-align: left;
vertical-align: top;
padding: 0em 2em 0em 0em;
font-size: 10pt;
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
div.variablelist dl dt
{
margin-bottom: 0.2em;
}
div.variablelist dl dd
{
margin: 0em 0em 0.5em 2em;
font-size: 10pt;
}
div.variablelist table tbody tr td p,
div.variablelist dl dd p
{
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
/*=============================================================================
Misc
=============================================================================*/
/* Title of books and articles in bibliographies */
span.title
{
font-style: italic;
}
span.underline
{
text-decoration: underline;
}
span.strikethrough
{
text-decoration: line-through;
}
/* Copyright, Legal Notice */
div div.legalnotice p
{
text-align: left
}
/*=============================================================================
Colors
=============================================================================*/
@media screen
{
/* Links */
a
{
color: #005a9c;
}
a:visited
{
color: #9c5a9c;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
{
text-decoration: none; /* no underline */
color: #000000;
}
/* Syntax Highlighting */
.keyword { color: #0000AA; }
.identifier { color: #000000; }
.special { color: #707070; }
.preprocessor { color: #402080; }
.char { color: teal; }
.comment { color: #800000; }
.string { color: teal; }
.number { color: teal; }
.white_bkd { background-color: #FFFFFF; }
.dk_grey_bkd { background-color: #999999; }
/* Copyright, Legal Notice */
.copyright
{
color: #666666;
font-size: small;
}
div div.legalnotice p
{
color: #666666;
}
/* Program listing */
pre.synopsis
{
border: 1px solid #DCDCDC;
}
.programlisting,
.screen
{
border: 1px solid #DCDCDC;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Blurbs */
div.note,
div.tip,
div.important,
div.caution,
div.warning,
div.sidebar
{
border: 1px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid #DCDCDC;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid #DCDCDC;
}
div.informaltable table tr th,
div.table table tr th
{
background-color: #F0F0F0;
border: 1px solid #DCDCDC;
}
/* Misc */
span.highlight
{
color: #00A000;
}
}
@media print
{
/* Links */
a
{
color: black;
}
a:visited
{
color: black;
}
.spirit-nav
{
display: none;
}
/* Program listing */
pre.synopsis
{
border: 1px solid gray;
}
.programlisting,
.screen
{
border: 1px solid gray;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid gray;
}
.informaltable table,
.table table
{
border: 1px solid gray;
border-collapse: collapse;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid gray;
}
div.informaltable table tr th,
div.table table tr th
{
border: 1px solid gray;
}
/* Misc */
span.highlight
{
font-weight: bold;
}
}

View File

@@ -1,598 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter<EFBFBD>1.<2E>Boost.Functional/Factory 1.0</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
<link rel="start" href="index.html" title="Chapter<65>1.<2E>Boost.Functional/Factory 1.0">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"></div>
<div class="chapter" lang="en">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="boost_functional_factory"></a>Chapter<EFBFBD>1.<2E>Boost.Functional/Factory 1.0</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Tobias</span> <span class="surname">Schwinger</span>
</h3></div></div>
<div><p class="copyright">Copyright <20> 2007, 2008 Tobias Schwinger</p></div>
<div><div class="legalnotice">
<a name="id934161"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="index.html#boost_functional_factory.brief_description">Brief Description</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_factory.background">Background</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_factory.reference"> Reference</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_factory.acknowledgements">Acknowledgements</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_factory.references">References</a></span></dt>
</dl>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_factory.brief_description"></a><a href="index.html#boost_functional_factory.brief_description" title="Brief Description">Brief Description</a></h2></div></div></div>
<p>
The template <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code> lets you encapsulate a <code class="computeroutput"><span class="keyword">new</span></code> expression as a function object, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">value_factory</span></code>
encapsulates a constructor invocation without <code class="computeroutput"><span class="keyword">new</span></code>.
</p>
<pre class="programlisting"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;()(</span><span class="identifier">arg1</span><span class="special">,</span><span class="identifier">arg2</span><span class="special">,</span><span class="identifier">arg3</span><span class="special">)</span>
<span class="comment">// same as new T(arg1,arg2,arg3)
</span>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">value_factory</span></code><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;()(</span><span class="identifier">arg1</span><span class="special">,</span><span class="identifier">arg2</span><span class="special">,</span><span class="identifier">arg3</span><span class="special">)</span>
<span class="comment">// same as T(arg1,arg2,arg3)
</span></pre>
<p>
For technical reasons the arguments to the function objects have to be LValues.
A factory that also accepts RValues can be composed using the <a href="http://www.boost.org/libs/functional/forward/doc/index.html" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">forward_adapter</span></code></a>
or <a href="http://www.boost.org/libs/bind/bind.html" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span></code></a>.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_factory.background"></a><a href="index.html#boost_functional_factory.background" title="Background">Background</a></h2></div></div></div>
<p>
In traditional Object Oriented Programming a Factory is an object implementing
an interface of one or more methods that construct objects conforming to known
interfaces.
</p>
<pre class="programlisting"><span class="comment">// assuming a_concrete_class and another_concrete_class are derived
</span><span class="comment">// from an_abstract_class
</span>
<span class="keyword">class</span> <span class="identifier">a_factory</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="keyword">virtual</span> <span class="identifier">an_abstract_class</span><span class="special">*</span> <span class="identifier">create</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
<span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">a_factory</span><span class="special">()</span> <span class="special">{</span> <span class="special">}</span>
<span class="special">};</span>
<head>
<!-- Copyright (C) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
<span class="keyword">class</span> <span class="identifier">a_concrete_factory</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">a_factory</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="keyword">virtual</span> <span class="identifier">an_abstract_class</span><span class="special">*</span> <span class="identifier">create</span><span class="special">()</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="keyword">new</span> <span class="identifier">a_concrete_class</span><span class="special">();</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="keyword">class</span> <span class="identifier">another_concrete_factory</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">a_factory</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="keyword">virtual</span> <span class="identifier">an_abstract_class</span><span class="special">*</span> <span class="identifier">create</span><span class="special">()</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="keyword">new</span> <span class="identifier">another_concrete_class</span><span class="special">();</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="comment">// [...]
</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<a href="http://www.boost.org/libs/ptr_container/doc/ptr_map.html" target="_top"><code class="computeroutput"><span class="identifier">__boost__ptr_map__</span></code></a><span class="special">&lt;</span><a href="http://www.sgi.com/tech/stl/string.html" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code></a><span class="special">,</span><span class="identifier">a_factory</span><span class="special">&gt;</span> <span class="identifier">factories</span><span class="special">;</span>
<span class="comment">// [...]
</span>
<span class="identifier">factories</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="string">"a_name"</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">a_factory</span><span class="special">&gt;(</span>
<span class="keyword">new</span> <span class="identifier">a_concrete_factory</span><span class="special">));</span>
<span class="identifier">factories</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="string">"another_name"</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">a_factory</span><span class="special">&gt;(</span>
<span class="keyword">new</span> <span class="identifier">another_concrete_factory</span><span class="special">));</span>
<span class="comment">// [...]
</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">an_abstract_factory</span><span class="special">&gt;</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">factories</span><span class="special">[</span><span class="identifier">some_name</span><span class="special">]-&gt;</span><span class="identifier">create</span><span class="special">();</span>
<span class="comment">// [...]
</span><span class="special">}</span>
</pre>
<p>
This approach has several drawbacks. The most obvious one is that there is
lots of boilerplate code. In other words there is too much code to express
a rather simple intention. We could use templates to get rid of some of it
but the approach remains inflexible:
</p>
<pre class="programlisting"><span class="identifier">o</span> <span class="identifier">We</span> <span class="identifier">may</span> <span class="identifier">want</span> <span class="identifier">a</span> <span class="identifier">factory</span> <span class="identifier">that</span> <span class="identifier">takes</span> <span class="identifier">some</span> <span class="identifier">arguments</span> <span class="identifier">that</span> <span class="identifier">are</span> <span class="identifier">forwarded</span> <span class="identifier">to</span>
<span class="identifier">the</span> <span class="identifier">constructor</span><span class="special">,</span>
<span class="identifier">o</span> <span class="identifier">we</span> <span class="identifier">will</span> <span class="identifier">probably</span> <span class="identifier">want</span> <span class="identifier">to</span> <span class="identifier">use</span> <span class="identifier">smart</span> <span class="identifier">pointers</span><span class="special">,</span>
<span class="identifier">o</span> <span class="identifier">we</span> <span class="identifier">may</span> <span class="identifier">want</span> <span class="identifier">several</span> <span class="identifier">member</span> <span class="identifier">functions</span> <span class="identifier">to</span> <span class="identifier">create</span> <span class="identifier">different</span> <span class="identifier">kinds</span> <span class="identifier">of</span>
<span class="identifier">objects</span><span class="special">,</span>
<span class="identifier">o</span> <span class="identifier">we</span> <span class="identifier">might</span> <span class="keyword">not</span> <span class="identifier">necessarily</span> <span class="identifier">need</span> <span class="identifier">a</span> <span class="identifier">polymorphic</span> <span class="identifier">base</span> <span class="keyword">class</span> <span class="keyword">for</span> <span class="identifier">the</span> <span class="identifier">objects</span><span class="special">,</span>
<span class="identifier">o</span> <span class="identifier">as</span> <span class="identifier">we</span> <span class="identifier">will</span> <span class="identifier">see</span><span class="special">,</span> <span class="identifier">we</span> <span class="keyword">do</span> <span class="keyword">not</span> <span class="identifier">need</span> <span class="identifier">a</span> <span class="identifier">factory</span> <span class="identifier">base</span> <span class="keyword">class</span> <span class="identifier">at</span> <span class="identifier">all</span><span class="special">,</span>
<span class="identifier">o</span> <span class="identifier">we</span> <span class="identifier">might</span> <span class="identifier">want</span> <span class="identifier">to</span> <span class="identifier">just</span> <span class="identifier">call</span> <span class="identifier">the</span> <span class="identifier">constructor</span> <span class="special">-</span> <span class="identifier">without</span> #<span class="keyword">new</span># <span class="identifier">to</span> <span class="identifier">create</span>
<span class="identifier">an</span> <span class="identifier">object</span> <span class="identifier">on</span> <span class="identifier">the</span> <span class="identifier">stack</span><span class="special">,</span> <span class="keyword">and</span>
<span class="identifier">o</span> <span class="identifier">finally</span> <span class="identifier">we</span> <span class="identifier">might</span> <span class="identifier">want</span> <span class="identifier">to</span> <span class="identifier">use</span> <span class="identifier">customized</span> <span class="identifier">memory</span> <span class="identifier">management</span><span class="special">.</span>
</pre>
<p>
Experience has shown that using function objects and generic Boost components
for their composition, Design Patterns that describe callback mechasisms (typically
requiring a high percentage of boilerplate code with pure Object Oriented methodology)
become implementable with just few code lines and without extra classes.
</p>
<p>
Factories are callback mechanisms for constructors, so we provide two class
templates, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">value_factory</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code>,
that encasulate object construction via direct application of the constructor
and the <code class="computeroutput"><span class="keyword">new</span></code> operator, respectively.
</p>
<p>
We let the function objects forward their arguments to the construction expressions
they encapsulate. Overthis <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code>
optionally allows the use of smart pointers and <a href="http://www.sgi.com/tech/stl/concepts/allocator.html" target="_top">Allocators</a>.
</p>
<p>
Compile-time polymorphism can be used where appropriate,
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">T</span> <span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">do_something</span><span class="special">()</span>
<span class="special">{</span>
<span class="comment">// [...]
</span> <span class="identifier">T</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">T</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">);</span>
<span class="comment">// for conceptually similar objects x we neither need virtual
</span> <span class="comment">// functions nor a common base class in this context.
</span> <span class="comment">// [...]
</span><span class="special">}</span>
</pre>
<p>
Now, to allow inhomogenous signaturs for the constructors of the types passed
in for <code class="computeroutput"><span class="identifier">T</span></code> we can use <code class="computeroutput"><span class="identifier">value_factory</span></code> and <a href="http://www.boost.org/libs/bind/bind.html" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span></code></a>
to normalize between them.
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">ValueFactory</span> <span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">do_something</span><span class="special">(</span><span class="identifier">ValueFactory</span> <span class="identifier">make_obj</span> <span class="special">=</span> <span class="identifier">ValueFactory</span><span class="special">())</span>
<span class="special">{</span>
<span class="comment">// [...]
</span> <span class="keyword">typename</span> <span class="identifier">ValueFactory</span><span class="special">::</span><span class="identifier">result_type</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">make_obj</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">);</span>
<span class="comment">// for conceptually similar objects x we neither need virtual
</span> <span class="comment">// functions nor a common base class in this context.
</span> <span class="comment">// [...]
</span><span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="comment">// [...]
</span>
<span class="identifier">do_something</span><span class="special">(</span><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">value_factory</span></code><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;());</span>
<span class="identifier">do_something</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">value_factory</span></code><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;(),</span><span class="identifier">_1</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="identifier">_2</span><span class="special">));</span>
<span class="comment">// construct X(a,b) and Y(a,5,b), respectively.
</span>
<span class="comment">// [...]
</span><span class="special">}</span>
</pre>
<p>
Maybe we want our objects to outlive the function's scope, in this case we
have to use dynamic allocation;
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Factory</span> <span class="special">&gt;</span>
<span class="identifier">whatever</span> <span class="identifier">do_something</span><span class="special">(</span><span class="identifier">Factory</span> <span class="identifier">new_obj</span> <span class="special">=</span> <span class="identifier">Factory</span><span class="special">())</span>
<span class="special">{</span>
<span class="keyword">typename</span> <span class="identifier">Factory</span><span class="special">::</span><span class="identifier">result_type</span> <span class="identifier">ptr</span> <span class="special">=</span> <span class="identifier">new_obj</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">);</span>
<span class="comment">// again, no common base class or virtual functions needed,
</span> <span class="comment">// we could enforce a polymorphic base by writing e.g.
</span> <span class="comment">// boost::shared_ptr&lt;base&gt;
</span> <span class="comment">// instead of
</span> <span class="comment">// typename Factory::result_type
</span> <span class="comment">// above.
</span> <span class="comment">// Note that we are also free to have the type erasure happen
</span> <span class="comment">// somewhere else (e.g. in the constructor of this function's
</span> <span class="comment">// result type).
</span>
<span class="comment">// [...]
</span><span class="special">}</span>
<span class="comment">// [... call do_something like above but with __factory__ instead
</span><span class="comment">// of __value_factory__]
</span></pre>
<p>
Although we might have created polymorphic objects in the previous example,
we have used compile time polymorphism for the factory. If we want to erase
the type of the factory and thus allow polymorphism at run time, we can use
<a href="http://www.boost.org/doc/html/function.html" target="_top">Boost.Function</a>
to do so. The first example can be rewritten as follows.
</p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">an_abstract_class</span><span class="special">*()</span> <span class="special">&gt;</span> <span class="identifier">a_factory</span><span class="special">;</span>
<span class="comment">// [...]
</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<a href="http://www.sgi.com/tech/stl/map.html" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code></a><span class="special">&lt;</span><a href="http://www.sgi.com/tech/stl/string.html" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code></a><span class="special">,</span><span class="identifier">a_factory</span><span class="special">&gt;</span> <span class="identifier">factories</span><span class="special">;</span>
<span class="comment">// [...]
</span>
<span class="identifier">factories</span><span class="special">[</span><span class="string">"a_name"</span><span class="special">]</span> <span class="special">=</span> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code><span class="special">&lt;</span><span class="identifier">a_concrete_class</span><span class="special">*&gt;();</span>
<span class="identifier">factories</span><span class="special">[</span><span class="string">"another_name"</span><span class="special">]</span> <span class="special">=</span>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">factory</span></code><span class="special">&lt;</span><span class="identifier">another_concrete_class</span><span class="special">*&gt;();</span>
<span class="comment">// [...]
</span><span class="special">}</span>
</pre>
<p>
Of course we can just as easy create factories that take arguments and/or return
<a href="http://www.boost.org/libs/smart_ptr/index.html" target="_top">Smart Pointers</a>.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_factory.reference"></a><a href="index.html#boost_functional_factory.reference" title=" Reference"> Reference</a></h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="index.html#boost_functional_factory.reference.value_factory">value_factory</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_factory.reference.factory">factory</a></span></dt>
</dl></div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_factory.reference.value_factory"></a><a href="index.html#boost_functional_factory.reference.value_factory" title="value_factory">value_factory</a></h3></div></div></div>
<a name="boost_functional_factory.reference.value_factory.description"></a><h4>
<a name="id936876"></a>
<a href="index.html#boost_functional_factory.reference.value_factory.description">Description</a>
</h4>
<p>
Function object template that invokes the constructor of the type <code class="computeroutput"><span class="identifier">T</span></code>.
</p>
<a name="boost_functional_factory.reference.value_factory.header"></a><h4>
<a name="id936914"></a>
<a href="index.html#boost_functional_factory.reference.value_factory.header">Header</a>
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">value_factory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<a name="boost_functional_factory.reference.value_factory.synopsis"></a><h4>
<a name="id936989"></a>
<a href="index.html#boost_functional_factory.reference.value_factory.synopsis">Synopsis</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T</span> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">value_factory</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">T</span></code></span></dt>
<dd><p>
an arbitrary type with at least one public constructor
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code></span></dt>
<dd><p>
argument LValues to a constructor of <code class="computeroutput"><span class="identifier">T</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">F</span></code></span></dt>
<dd><p>
the type <code class="computeroutput"><span class="identifier">value_factory</span><span class="special">&lt;</span><span class="identifier">F</span><span class="special">&gt;</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">f</span></code></span></dt>
<dd><p>
an instance object of <code class="computeroutput"><span class="identifier">F</span></code>
</p></dd>
</dl>
</div>
<a name="boost_functional_factory.reference.value_factory.expression_semantics"></a><h4>
<a name="id937226"></a>
<a href="index.html#boost_functional_factory.reference.value_factory.expression_semantics">Expression
Semantics</a>
</h4>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
creates an object of type <code class="computeroutput"><span class="identifier">F</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
creates an object of type <code class="computeroutput"><span class="identifier">F</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
returns <code class="computeroutput"><span class="identifier">T</span><span class="special">(</span><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span><span class="special">)</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">::</span><span class="identifier">result_type</span></code>
</p>
</td>
<td>
<p>
is the type <code class="computeroutput"><span class="identifier">T</span></code>.
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="boost_functional_factory.reference.value_factory.limits"></a><h4>
<a name="id937498"></a>
<a href="index.html#boost_functional_factory.reference.value_factory.limits">Limits</a>
</h4>
<p>
The macro BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY can be defined to set
the maximum arity. It defaults to 10.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_factory.reference.factory"></a><a href="index.html#boost_functional_factory.reference.factory" title="factory">factory</a></h3></div></div></div>
<a name="boost_functional_factory.reference.factory.description"></a><h4>
<a name="id937545"></a>
<a href="index.html#boost_functional_factory.reference.factory.description">Description</a>
</h4>
<p>
Function object template that dynamically constructs a pointee object for
the type of pointer given as template argument. Smart pointers may be used
for the template argument, given that <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">pointee</span><span class="special">&lt;</span><span class="identifier">Pointer</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
yields the pointee type.
</p>
<p>
If an <span class="underline">_allocator</span>_ is given, it is used
for memory allocation and the placement form of the <code class="computeroutput"><span class="keyword">new</span></code>
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 <code class="computeroutput"><span class="identifier">Pointer</span></code>
(thus it must be a __smart<span class="underline">pointer</span>_
that provides a suitable constructor, such as <a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span></code></a>).
</p>
<p>
If a third template argument is <code class="computeroutput"><span class="identifier">factory_passes_alloc_to_smart_pointer</span></code>,
the allocator itself is used for the third constructor argument of <code class="computeroutput"><span class="identifier">Pointer</span></code> (<a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span></code></a> then uses the allocator
to manage the memory of its seperately allocated reference counter).
</p>
<a name="boost_functional_factory.reference.factory.header"></a><h4>
<a name="id937729"></a>
<a href="index.html#boost_functional_factory.reference.factory.header">Header</a>
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">factory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<a name="boost_functional_factory.reference.factory.synopsis"></a><h4>
<a name="id937804"></a>
<a href="index.html#boost_functional_factory.reference.factory.synopsis">Synopsis</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">enum</span> <span class="identifier">factory_alloc_propagation</span>
<span class="special">{</span>
<span class="identifier">factory_alloc_for_pointee_and_deleter</span><span class="special">,</span>
<span class="identifier">factory_passes_alloc_to_smart_pointer</span>
<span class="special">};</span>
<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Pointer</span><span class="special">,</span>
<span class="keyword">class</span> <span class="identifier">Allocator</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none_t</span><span class="special">,</span>
<span class="identifier">factory_alloc_propagation</span> <span class="identifier">AllocProp</span> <span class="special">=</span>
<span class="identifier">factory_alloc_for_pointee_and_deleter</span> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">factory</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">T</span></code></span></dt>
<dd><p>
an arbitrary type with at least one public constructor
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">P</span></code></span></dt>
<dd><p>
pointer or smart pointer to <code class="computeroutput"><span class="identifier">T</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code></span></dt>
<dd><p>
argument LValues to a constructor of <code class="computeroutput"><span class="identifier">T</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">F</span></code></span></dt>
<dd><p>
the type <code class="computeroutput"><span class="identifier">factory</span><span class="special">&lt;</span><span class="identifier">P</span><span class="special">&gt;</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">f</span></code></span></dt>
<dd><p>
an instance object of <code class="computeroutput"><span class="identifier">F</span></code>
</p></dd>
</dl>
</div>
<a name="boost_functional_factory.reference.factory.expression_semantics"></a><h4>
<a name="id938169"></a>
<a href="index.html#boost_functional_factory.reference.factory.expression_semantics">Expression
Semantics</a>
</h4>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
creates an object of type <code class="computeroutput"><span class="identifier">F</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
creates an object of type <code class="computeroutput"><span class="identifier">F</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
dynamically creates an object of type <code class="computeroutput"><span class="identifier">T</span></code>
using <code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code> as arguments for the constructor
invocation.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">F</span><span class="special">::</span><span class="identifier">result_type</span></code>
</p>
</td>
<td>
<p>
is the type <code class="computeroutput"><span class="identifier">P</span></code> with
top-level cv-qualifiers removed.
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="boost_functional_factory.reference.factory.limits"></a><h4>
<a name="id938440"></a>
<a href="index.html#boost_functional_factory.reference.factory.limits">Limits</a>
</h4>
<p>
The macro BOOST_FUNCTIONAL_FACTORY_MAX_ARITY can be defined to set the maximum
arity. It defaults to 10.
</p>
</div>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_factory.acknowledgements"></a><a href="index.html#boost_functional_factory.acknowledgements" title="Acknowledgements">Acknowledgements</a></h2></div></div></div>
<p>
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
are a factored-out generalization of this idea.
</p>
<p>
Dave Abrahams suggested Smart Pointer support for exception safety, providing
useful hints for the implementation.
</p>
<p>
Joel de Guzman's documentation style was copied from Fusion.
</p>
<p>
Further, I want to thank Peter Dimov for sharing his insights on language details
and their evolution.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_factory.references"></a><a href="index.html#boost_functional_factory.references" title="References">References</a></h2></div></div></div>
<div class="orderedlist"><ol type="1">
<li>
<a href="http://en.wikipedia.org/wiki/Design_Patterns" target="_top">Design Patterns</a>,
Gamma et al. - Addison Wesley Publishing, 1995
</li>
<li>
<a href="http://www.sgi.com/tech/stl/" target="_top">Standard Template Library Programmer's
Guide</a>, Hewlett-Packard Company, 1994
</li>
<li>
<a href="http://www.boost.org/libs/bind/bind.html" target="_top">Boost.Bind</a>,
Peter Dimov, 2001-2005
</li>
<li>
<a href="http://www.boost.org/doc/html/function.html" target="_top">Boost.Function</a>,
Douglas Gregor, 2001-2004
</li>
</ol></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 01, 2008 at 21:44:52 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"></div>
</body>
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) -->
<title>Redirect to generated documentation</title>
<meta http-equiv="refresh" content="0; URL=http://boost-sandbox.sourceforge.net/libs/functional/factory/doc/html/">
</head>
<body>
Automatic redirection failed, please go to
<a href="http://boost-sandbox.sourceforge.net/libs/functional/factory/doc/html/">http://boost-sandbox.sourceforge.net/libs/functional/factory/doc/html/</a>
</body>
</html>

View File

@@ -1,528 +0,0 @@
/*=============================================================================
Copyright (c) 2004 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to 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)
=============================================================================*/
/*=============================================================================
Body defaults
=============================================================================*/
body
{
margin: 1em;
font-family: sans-serif;
}
/*=============================================================================
Paragraphs
=============================================================================*/
p
{
text-align: left;
font-size: 10pt;
line-height: 1.15;
}
/*=============================================================================
Program listings
=============================================================================*/
/* Code on paragraphs */
p tt.computeroutput
{
font-size: 9pt;
}
pre.synopsis
{
font-size: 90%;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
.programlisting,
.screen
{
font-size: 9pt;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
/* Program listings in tables don't get borders */
td .programlisting,
td .screen
{
margin: 0pc 0pc 0pc 0pc;
padding: 0pc 0pc 0pc 0pc;
}
/*=============================================================================
Headings
=============================================================================*/
h1, h2, h3, h4, h5, h6
{
text-align: left;
margin: 1em 0em 0.5em 0em;
font-weight: bold;
}
h1 { font: 140% }
h2 { font: bold 140% }
h3 { font: bold 130% }
h4 { font: bold 120% }
h5 { font: italic 110% }
h6 { font: italic 100% }
/* Top page titles */
title,
h1.title,
h2.title
h3.title,
h4.title,
h5.title,
h6.title,
.refentrytitle
{
font-weight: bold;
margin-bottom: 1pc;
}
h1.title { font-size: 140% }
h2.title { font-size: 140% }
h3.title { font-size: 130% }
h4.title { font-size: 120% }
h5.title { font-size: 110% }
h6.title { font-size: 100% }
.section h1
{
margin: 0em 0em 0.5em 0em;
font-size: 140%;
}
.section h2 { font-size: 140% }
.section h3 { font-size: 130% }
.section h4 { font-size: 120% }
.section h5 { font-size: 110% }
.section h6 { font-size: 100% }
/* Code on titles */
h1 tt.computeroutput { font-size: 140% }
h2 tt.computeroutput { font-size: 140% }
h3 tt.computeroutput { font-size: 130% }
h4 tt.computeroutput { font-size: 120% }
h5 tt.computeroutput { font-size: 110% }
h6 tt.computeroutput { font-size: 100% }
/*=============================================================================
Author
=============================================================================*/
h3.author
{
font-size: 100%
}
/*=============================================================================
Lists
=============================================================================*/
li
{
font-size: 10pt;
line-height: 1.3;
}
/* Unordered lists */
ul
{
text-align: left;
}
/* Ordered lists */
ol
{
text-align: left;
}
/*=============================================================================
Links
=============================================================================*/
a
{
text-decoration: none; /* no underline */
}
a:hover
{
text-decoration: underline;
}
/*=============================================================================
Spirit style navigation
=============================================================================*/
.spirit-nav
{
text-align: right;
}
.spirit-nav a
{
color: white;
padding-left: 0.5em;
}
.spirit-nav img
{
border-width: 0px;
}
/*=============================================================================
Table of contents
=============================================================================*/
.toc
{
margin: 1pc 4% 0pc 4%;
padding: 0.1pc 1pc 0.1pc 1pc;
font-size: 80%;
line-height: 1.15;
}
.boost-toc
{
float: right;
padding: 0.5pc;
}
/*=============================================================================
Tables
=============================================================================*/
.table-title,
div.table p.title
{
margin-left: 4%;
padding-right: 0.5em;
padding-left: 0.5em;
}
.informaltable table,
.table table
{
width: 92%;
margin-left: 4%;
margin-right: 4%;
}
div.informaltable table,
div.table table
{
padding: 4px;
}
/* Table Cells */
div.informaltable table tr td,
div.table table tr td
{
padding: 0.5em;
text-align: left;
font-size: 9pt;
}
div.informaltable table tr th,
div.table table tr th
{
padding: 0.5em 0.5em 0.5em 0.5em;
border: 1pt solid white;
font-size: 80%;
}
/*=============================================================================
Blurbs
=============================================================================*/
div.note,
div.tip,
div.important,
div.caution,
div.warning,
div.sidebar
{
font-size: 9pt; /* A little bit smaller than the main text */
line-height: 1.2;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.0pc 0.5pc;
}
div.sidebar img
{
padding: 1pt;
}
/*=============================================================================
Callouts
=============================================================================*/
.line_callout_bug img
{
float: left;
position:relative;
left: 4px;
top: -12px;
clear: left;
margin-left:-22px;
}
.callout_bug img
{
}
/*=============================================================================
Variable Lists
=============================================================================*/
/* Make the terms in definition lists bold */
div.variablelist dl dt,
span.term
{
font-weight: bold;
font-size: 10pt;
}
div.variablelist table tbody tr td
{
text-align: left;
vertical-align: top;
padding: 0em 2em 0em 0em;
font-size: 10pt;
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
div.variablelist dl dt
{
margin-bottom: 0.2em;
}
div.variablelist dl dd
{
margin: 0em 0em 0.5em 2em;
font-size: 10pt;
}
div.variablelist table tbody tr td p,
div.variablelist dl dd p
{
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
/*=============================================================================
Misc
=============================================================================*/
/* Title of books and articles in bibliographies */
span.title
{
font-style: italic;
}
span.underline
{
text-decoration: underline;
}
span.strikethrough
{
text-decoration: line-through;
}
/* Copyright, Legal Notice */
div div.legalnotice p
{
text-align: left
}
/*=============================================================================
Colors
=============================================================================*/
@media screen
{
/* Links */
a
{
color: #005a9c;
}
a:visited
{
color: #9c5a9c;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
{
text-decoration: none; /* no underline */
color: #000000;
}
/* Syntax Highlighting */
.keyword { color: #0000AA; }
.identifier { color: #000000; }
.special { color: #707070; }
.preprocessor { color: #402080; }
.char { color: teal; }
.comment { color: #800000; }
.string { color: teal; }
.number { color: teal; }
.white_bkd { background-color: #FFFFFF; }
.dk_grey_bkd { background-color: #999999; }
/* Copyright, Legal Notice */
.copyright
{
color: #666666;
font-size: small;
}
div div.legalnotice p
{
color: #666666;
}
/* Program listing */
pre.synopsis
{
border: 1px solid #DCDCDC;
}
.programlisting,
.screen
{
border: 1px solid #DCDCDC;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Blurbs */
div.note,
div.tip,
div.important,
div.caution,
div.warning,
div.sidebar
{
border: 1px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid #DCDCDC;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid #DCDCDC;
}
div.informaltable table tr th,
div.table table tr th
{
background-color: #F0F0F0;
border: 1px solid #DCDCDC;
}
/* Misc */
span.highlight
{
color: #00A000;
}
}
@media print
{
/* Links */
a
{
color: black;
}
a:visited
{
color: black;
}
.spirit-nav
{
display: none;
}
/* Program listing */
pre.synopsis
{
border: 1px solid gray;
}
.programlisting,
.screen
{
border: 1px solid gray;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid gray;
}
.informaltable table,
.table table
{
border: 1px solid gray;
border-collapse: collapse;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid gray;
}
div.informaltable table tr th,
div.table table tr th
{
border: 1px solid gray;
}
/* Misc */
span.highlight
{
font-weight: bold;
}
}

View File

@@ -1,564 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter<EFBFBD>1.<2E>Boost.Functional/Forward 1.0</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
<link rel="start" href="index.html" title="Chapter<65>1.<2E>Boost.Functional/Forward 1.0">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"></div>
<div class="chapter" lang="en">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="boost_functional_forward"></a>Chapter<EFBFBD>1.<2E>Boost.Functional/Forward 1.0</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Tobias</span> <span class="surname">Schwinger</span>
</h3></div></div>
<div><p class="copyright">Copyright <20> 2007, 2008 Tobias Schwinger</p></div>
<div><div class="legalnotice">
<a name="id934161"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="index.html#boost_functional_forward.brief_description">Brief Description</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_forward.background">Background</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_forward.reference"> Reference</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_forward.acknowledgements">Acknowledgements</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_forward.references">References</a></span></dt>
</dl>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_forward.brief_description"></a><a href="index.html#boost_functional_forward.brief_description" title="Brief Description">Brief Description</a></h2></div></div></div>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">forward_adapter</span></code> provides a reusable adapter
template for function objects. It forwards RValues as references to const,
while leaving LValues as-is.
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">g</span> <span class="comment">// function object that only accept LValues
</span><span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T2</span> <span class="special">&gt;</span>
<span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span> <span class="special">&amp;</span> <span class="identifier">t0</span><span class="special">,</span> <span class="identifier">T1</span> <span class="special">&amp;</span> <span class="identifier">t1</span><span class="special">,</span> <span class="identifier">T2</span> <span class="special">&amp;</span> <span class="identifier">t2</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<head>
<!-- Copyright (C) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
<span class="keyword">typedef</span> <span class="keyword">void</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// Adapted version also accepts RValues and forwards
</span><span class="comment">// them as references to const, LValues as-is
</span><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">forward_adapter</span><span class="special">&lt;</span><span class="identifier">g</span><span class="special">&gt;</span> <span class="identifier">f</span><span class="special">;</span>
</pre>
<p>
Another adapter, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lighweight_forward_adapter</span></code> allows forwarding
with some help from the user accepting and unwrapping reference wrappers (see
<a href="http://www.boost.org/doc/html/ref.html" target="_top">Boost.Ref</a>) for
reference arguments, const qualifying all other arguments.
</p>
<p>
The target functions must be compatible with <a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top">Boost.ResultOf</a>,
and so are the adapters.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_forward.background"></a><a href="index.html#boost_functional_forward.background" title="Background">Background</a></h2></div></div></div>
<p>
Let's suppose we have some function <code class="computeroutput"><span class="identifier">f</span></code>
that we can call like this:
</p>
<pre class="programlisting"><span class="identifier">f</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="identifier">a_variable</span><span class="special">);</span>
</pre>
<p>
Now we want to write another, generic function <code class="computeroutput"><span class="identifier">g</span></code>
that can be called the same way and returns some object that calls <code class="computeroutput"><span class="identifier">f</span></code> with the same arguments.
</p>
<pre class="programlisting"><span class="identifier">f</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="identifier">a_variable</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">g</span><span class="special">(</span><span class="identifier">f</span><span class="special">,</span><span class="number">123</span><span class="special">,</span><span class="identifier">a_variable</span><span class="special">).</span><span class="identifier">call_f</span><span class="special">()</span>
</pre>
<a name="boost_functional_forward.background.why_would_we_want_to_do_it__anyway_"></a><h3>
<a name="id934701"></a>
<a href="index.html#boost_functional_forward.background.why_would_we_want_to_do_it__anyway_">Why
would we want to do it, anyway?</a>
</h3>
<p>
Maybe we want to run <code class="computeroutput"><span class="identifier">f</span></code> several
times. Or maybe we want to run it within another thread. Maybe we just want
to encapsulate the call expression for now, and then use it with other code
that allows to compose more complex expressions in order to decompose it with
C++ templates and have the compiler generate some machinery that eventually
calls <code class="computeroutput"><span class="identifier">f</span></code> at runtime (in other
words; apply a technique that is commonly referred to as Expression Templates).
</p>
<a name="boost_functional_forward.background.now__how_do_we_do_it_"></a><h3>
<a name="id934755"></a>
<a href="index.html#boost_functional_forward.background.now__how_do_we_do_it_">Now,
how do we do it?</a>
</h3>
<p>
The bad news is: It's impossible.
</p>
<p>
That is so because there is a slight difference between a variable and an expression
that evaluates to its value: Given
</p>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">y</span><span class="special">;</span>
<span class="keyword">int</span> <span class="keyword">const</span> <span class="identifier">z</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
</pre>
<p>
and
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">func1</span><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">);</span>
</pre>
<p>
we can call
</p>
<pre class="programlisting"><span class="identifier">func1</span><span class="special">(</span><span class="identifier">y</span><span class="special">);</span> <span class="comment">// x is a reference to a non-const object
</span><span class="identifier">func1</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span> <span class="comment">// x is a reference to a const object
</span></pre>
<p>
where
</p>
<pre class="programlisting"><span class="identifier">func1</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="comment">// fails to compile.
</span></pre>
<p>
This way we can safely have <code class="computeroutput"><span class="identifier">func1</span></code>
store its reference argument and the compiler keeps us from storing a reference
to an object with temporary lifetime.
</p>
<p>
It is important to realize that non-constness and whether an object binds to
a non-const reference parameter are two different properties. The latter is
the distinction between LValues and RValues. The names stem from the left hand
side and the right hand side of assignment expressions, thus LValues are typically
the ones you can assign to, and RValues the temporary results from the right
hand side expression.
</p>
<pre class="programlisting"><span class="identifier">y</span> <span class="special">=</span> <span class="number">1</span><span class="special">+</span><span class="number">2</span><span class="special">;</span> <span class="comment">// a is LValue, 1+2 is the expression producing the RValue,
</span><span class="comment">// 1+2 = a; // usually makes no sense.
</span>
<span class="identifier">func1</span><span class="special">(</span><span class="identifier">y</span><span class="special">);</span> <span class="comment">// works, because y is an LValue
</span><span class="comment">// func1(1+2); // fails to compile, because we only got an RValue.
</span></pre>
<p>
If we add const qualification on the parameter, our function also accepts RValues:
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">func2</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">);</span>
<span class="comment">// [...] function scope:
</span><span class="identifier">func2</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="comment">// x is a reference to a const temporary, object,
</span><span class="identifier">func2</span><span class="special">(</span><span class="identifier">y</span><span class="special">);</span> <span class="comment">// x is a reference to a const object, while y is not const, and
</span><span class="identifier">func2</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span> <span class="comment">// x is a reference to a const object, just like z.
</span></pre>
<p>
In all cases, the argument <code class="computeroutput"><span class="identifier">x</span></code>
in <code class="computeroutput"><span class="identifier">func2</span></code> is a const-qualified
LValue. We can use function overloading to identify non-const LValues:
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">func3</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">);</span> <span class="comment">// #1
</span><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">func3</span><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">);</span> <span class="comment">// #2
</span>
<span class="comment">// [...] function scope:
</span><span class="identifier">func3</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="comment">// x is a reference to a const, temporary object in #1,
</span><span class="identifier">func3</span><span class="special">(</span><span class="identifier">y</span><span class="special">);</span> <span class="comment">// x is a reference to a non-const object in #2, and
</span><span class="identifier">func3</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span> <span class="comment">// x is a reference to a const object in #1.
</span></pre>
<p>
Note that all arguments <code class="computeroutput"><span class="identifier">x</span></code> in
the overloaded function <code class="computeroutput"><span class="identifier">func3</span></code>
are LValues. In fact, there is no way to transport RValues into a function
as-is in C++98. Also note that we can't distinguish between what used to be
a const qualified LValue and an RValue.
</p>
<p>
That's as close as we can get to a generic forwarding function <code class="computeroutput"><span class="identifier">g</span></code> as described above by the means of C++
98. See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_top">The
Forwarding Problem</a> for a very detailed discussion including solutions
that require language changes.
</p>
<p>
Now, for actually implementing it, we need 2^N overloads for N parameters (each
with and without const qualifier) for each number of arguments (that is 2^(Nmax+1)
- 2^Nmin). Right, that means the compile-time complexity is O(2^N), however
the factor is low so it works quite well for a reasonable number (&lt; 10)
of arguments.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_forward.reference"></a><a href="index.html#boost_functional_forward.reference" title=" Reference"> Reference</a></h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="index.html#boost_functional_forward.reference.forward_adapter">forward_adapter</a></span></dt>
<dt><span class="section"><a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter">lightweight_forward_adapter</a></span></dt>
</dl></div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_forward.reference.forward_adapter"></a><a href="index.html#boost_functional_forward.reference.forward_adapter" title="forward_adapter">forward_adapter</a></h3></div></div></div>
<a name="boost_functional_forward.reference.forward_adapter.description"></a><h4>
<a name="id935594"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.description">Description</a>
</h4>
<p>
Function object adapter template whose instances are callable with LValue
and RValue arguments. RValue arguments are forwarded as reference-to-const
typed LValues.
</p>
<p>
An arity can be given as second, numeric non-type template argument to restrict
forwarding to a specific arity. If a third, numeric non-type template argument
is present, the second and third template argument are treated as minimum
and maximum arity, respectively. Specifying an arity can be helpful to improve
the readability of diagnostic messages and compile time performance.
</p>
<p>
<a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top">Boost.ResultOf</a>
can be used to determine the result types of specific call expressions.
</p>
<a name="boost_functional_forward.reference.forward_adapter.header"></a><h4>
<a name="id935646"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.header">Header</a>
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">forward_adapter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<a name="boost_functional_forward.reference.forward_adapter.synopsis"></a><h4>
<a name="id935721"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.synopsis">Synopsis</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span>
<span class="keyword">int</span> <span class="identifier">Arity_Or_MinArity</span> <span class="special">=</span> <span class="emphasis"><em>unspecified</em></span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">MaxArity</span> <span class="special">=</span> <span class="emphasis"><em>unspecified</em></span> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">forward_adapter</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">F</span></code></span></dt>
<dd><p>
a possibly const qualified function object type or reference type thereof
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">f</span></code></span></dt>
<dd><p>
an object convertible to <code class="computeroutput"><span class="identifier">F</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">FA</span></code></span></dt>
<dd><p>
the type <code class="computeroutput"><span class="identifier">forward_adapter</span><span class="special">&lt;</span><span class="identifier">F</span><span class="special">&gt;</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">fa</span></code></span></dt>
<dd><p>
an instance object of <code class="computeroutput"><span class="identifier">FA</span></code>,
initialized with <code class="computeroutput"><span class="identifier">f</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code></span></dt>
<dd><p>
arguments to <code class="computeroutput"><span class="identifier">fa</span></code>
</p></dd>
</dl>
</div>
<p>
The result type of a target function invocation must be
</p>
<pre class="programlisting"><a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">result_of</span></code></a><span class="special">&lt;</span><span class="identifier">F</span><span class="special">*(</span><span class="identifier">TA0</span> <span class="special">[</span><span class="keyword">const</span><span class="special">]&amp;...</span><span class="identifier">TAN</span> <span class="special">[</span><span class="keyword">const</span><span class="special">]&amp;])&gt;::</span><span class="identifier">type</span>
</pre>
<p>
where <code class="computeroutput"><span class="identifier">TA0</span></code>...<code class="computeroutput"><span class="identifier">TAN</span></code> denote the argument types of <code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code>.
</p>
<a name="boost_functional_forward.reference.forward_adapter.expression_semantics"></a><h4>
<a name="id936177"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.expression_semantics">Expression
Semantics</a>
</h4>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">FA</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
creates an adapter, initializes the target function with <code class="computeroutput"><span class="identifier">f</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">FA</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
creates an adapter, attempts to use <code class="computeroutput"><span class="identifier">F</span></code>'s
default constructor.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">fa</span><span class="special">(</span><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
calls <code class="computeroutput"><span class="identifier">f</span></code> with with
arguments <code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code>.
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="boost_functional_forward.reference.forward_adapter.limits"></a><h4>
<a name="id936405"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.limits">Limits</a>
</h4>
<p>
The macro BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY can be defined to set
the maximum call arity. It defaults to 6.
</p>
<a name="boost_functional_forward.reference.forward_adapter.complexity"></a><h4>
<a name="id936434"></a>
<a href="index.html#boost_functional_forward.reference.forward_adapter.complexity">Complexity</a>
</h4>
<p>
Preprocessing time: O(2^N), where N is the arity limit. Compile time: O(2^N),
where N depends on the arity range. Run time: O(0) if the compiler inlines,
O(1) otherwise.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_forward.reference.lightweight_forward_adapter"></a><a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter" title="lightweight_forward_adapter">lightweight_forward_adapter</a></h3></div></div></div>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.description"></a><h4>
<a name="id936485"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.description">Description</a>
</h4>
<p>
Function object adapter template whose instances are callable with LValue
and RValue arguments. All arguments are forwarded as reference-to-const typed
LValues, except for reference wrappers which are unwrapped and may yield
non-const LValues.
</p>
<p>
An arity can be given as second, numeric non-type template argument to restrict
forwarding to a specific arity. If a third, numeric non-type template argument
is present, the second and third template argument are treated as minimum
and maximum arity, respectively. Specifying an arity can be helpful to improve
the readability of diagnostic messages and compile time performance.
</p>
<p>
<a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top">Boost.ResultOf</a>
can be used to determine the result types of specific call expressions.
</p>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.header"></a><h4>
<a name="id936540"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.header">Header</a>
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">lightweight_forward_adapter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.synopsis"></a><h4>
<a name="id936616"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.synopsis">Synopsis</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span>
<span class="keyword">int</span> <span class="identifier">Arity_Or_MinArity</span> <span class="special">=</span> <span class="emphasis"><em>unspecified</em></span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">MaxArity</span> <span class="special">=</span> <span class="emphasis"><em>unspecified</em></span> <span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">lightweight_forward_adapter</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">F</span></code></span></dt>
<dd><p>
a possibly const qualified function object type or reference type thereof
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">f</span></code></span></dt>
<dd><p>
an object convertible to <code class="computeroutput"><span class="identifier">F</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">FA</span></code></span></dt>
<dd><p>
the type <code class="computeroutput"><span class="identifier">lightweight_forward_adapter</span><span class="special">&lt;</span><span class="identifier">F</span><span class="special">&gt;</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">fa</span></code></span></dt>
<dd><p>
an instance of <code class="computeroutput"><span class="identifier">FA</span></code>, initialized
with <code class="computeroutput"><span class="identifier">f</span></code>
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code></span></dt>
<dd><p>
arguments to <code class="computeroutput"><span class="identifier">fa</span></code>
</p></dd>
</dl>
</div>
<p>
The result type of a target function invocation must be
</p>
<pre class="programlisting"><a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">result_of</span></code></a><span class="special">&lt;</span><span class="identifier">F</span><span class="special">*(</span><span class="identifier">TA0</span> <span class="special">[</span><span class="keyword">const</span><span class="special">]&amp;...</span><span class="identifier">TAN</span> <span class="special">[</span><span class="keyword">const</span><span class="special">]&amp;])&gt;::</span><span class="identifier">type</span>
</pre>
<p>
where <code class="computeroutput"><span class="identifier">TA0</span></code>...<code class="computeroutput"><span class="identifier">TAN</span></code> denote the argument types of <code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code>.
</p>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.expression_semantics"></a><h4>
<a name="id937073"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.expression_semantics">Expression
Semantics</a>
</h4>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">FA</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
creates an adapter, initializes the target function with <code class="computeroutput"><span class="identifier">f</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">FA</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
creates an adapter, attempts to use <code class="computeroutput"><span class="identifier">F</span></code>'s
default constructor.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">fa</span><span class="special">(</span><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
calls <code class="computeroutput"><span class="identifier">f</span></code> with with
const arguments <code class="computeroutput"><span class="identifier">a0</span></code>...<code class="computeroutput"><span class="identifier">aN</span></code>. If <code class="computeroutput"><span class="identifier">aI</span></code>
is a reference wrapper it is unwrapped.
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.limits"></a><h4>
<a name="id937311"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.limits">Limits</a>
</h4>
<p>
The macro BOOST_FUNCTIONAL_LIGHTWEIGHT_FORWARD_ADAPTER_MAX_ARITY can be defined
to set the maximum call arity. It defaults to 10.
</p>
<a name="boost_functional_forward.reference.lightweight_forward_adapter.complexity"></a><h4>
<a name="id937342"></a>
<a href="index.html#boost_functional_forward.reference.lightweight_forward_adapter.complexity">Complexity</a>
</h4>
<p>
Preprocessing time: O(N), where N is the arity limit. Compile time: O(N),
where N is the effective arity of a call. Run time: O(0) if the compiler
inlines, O(1) otherwise.
</p>
</div>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_forward.acknowledgements"></a><a href="index.html#boost_functional_forward.acknowledgements" title="Acknowledgements">Acknowledgements</a></h2></div></div></div>
<p>
As these utilities are factored out of the <a href="http://www.boost.org/libs/fusion/doc/html/index.html" target="_top">Boost.Fusion</a>
functional module, I want to thank Dan Marsden and Joel de Guzman for letting
me participate in the development of that great library in the first place.
</p>
<p>
Further, I want to credit the authors of the references below, for their in-depth
investigation of the problem and the solution implemented here.
</p>
<p>
Last but not least I want to thank Vesa Karnoven and Paul Mensonides for the
Boost Preprocessor library. Without it, I would have ended up with an external
code generator for this one.
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_forward.references"></a><a href="index.html#boost_functional_forward.references" title="References">References</a></h2></div></div></div>
<div class="orderedlist"><ol type="1">
<li>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_top">The
Forwarding Problem</a>, Peter Dimov, Howard E. Hinnant, David Abrahams,
2002
</li>
<li>
<a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_top">Boost.ResultOf</a>,
Douglas Gregor, 2004
</li>
<li>
<a href="http://www.boost.org/doc/html/ref.html" target="_top">Boost.Ref</a>, Jaakko
Jarvi, Peter Dimov, Douglas Gregor, David Abrahams, 1999-2002
</li>
</ol></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 01, 2008 at 19:58:50 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"></div>
</body>
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) -->
<title>Redirect to generated documentation</title>
<meta http-equiv="refresh" content="0; URL=http://boost-sandbox.sourceforge.net/libs/functional/forward/doc/html/">
</head>
<body>
Automatic redirection failed, please go to
<a href="http://boost-sandbox.sourceforge.net/libs/functional/forward/doc/html/">http://boost-sandbox.sourceforge.net/libs/functional/forward/doc/html/</a>
</body>
</html>

View File

@@ -33,9 +33,9 @@
</span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</pre></div>
<div class="refsect1">
<a name="id813516"></a><h2>Description</h2>
<a name="id821556"></a><h2>Description</h2>
<p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When specified by the user, this macro must be a non-negative integer number.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/getting_started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

View File

@@ -7,7 +7,7 @@
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="up" href="reference.html#header.boost.functional.overloaded_function.config_hpp" title="Header &lt;boost/functional/overloaded_function/config.hpp&gt;">
<link rel="prev" href="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">
<link rel="next" href="boost_functional_overloadedfunction/Acknowledgments.html" title="Acknowledgments">
<link rel="next" href="boost_functional_overloadedfunction/acknowledgments.html" title="Acknowledgments">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.functional.overloaded_function.config_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_functional_overloadedfunction/Acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.functional.overloaded_function.config_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_functional_overloadedfunction/acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX"></a><div class="titlepage"></div>
@@ -33,9 +33,9 @@
</span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</pre></div>
<div class="refsect1">
<a name="id813573"></a><h2>Description</h2>
<a name="id821614"></a><h2>Description</h2>
<p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When defined by the user, this macro must be an integer number greater or equal than 2 (because at least two distinct functions need to be specified in order to define an overload).</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/getting_started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
@@ -48,7 +48,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.functional.overloaded_function.config_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_functional_overloadedfunction/Acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.functional.overloaded_function.config_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_functional_overloadedfunction/acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -36,12 +36,12 @@
<a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a><span class="special">&lt;</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">,</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">,</span><span class="special">...</span><span class="special">&gt;</span>
<span class="identifier">make_overloaded_function</span><span class="special">(</span><span class="identifier">F1</span> f1<span class="special">,</span> <span class="identifier">F2</span> f2<span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id813336"></a><h2>Description</h2>
<a name="id821376"></a><h2>Description</h2>
<p>This function template creates and returns an <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> object that overloads all the specified functions <code class="computeroutput">f1</code>, <code class="computeroutput">f2</code>, etc.</p>
<p>The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>. This is especially useful when the explicit type of the returned <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> object does not need to be known (e.g., when used with Boost.Typeof's <code class="computeroutput">BOOST_AUTO</code>, C++11 <code class="computeroutput">auto</code>, or when the overloaded function object is handled using a function template parameter, see the <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section).</p>
<p>The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>. This is especially useful when the explicit type of the returned <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> object does not need to be known (e.g., when used with Boost.Typeof's <code class="computeroutput">BOOST_AUTO</code>, C++11 <code class="computeroutput">auto</code>, or when the overloaded function object is handled using a function template parameter, see the <a class="link" href="../boost_functional_overloadedfunction/tutorial.html" title="Tutorial"> Tutorial</a> section).</p>
<p>The maximum number of functions to overload is given by the <code class="computeroutput"><code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code></code> configuration macro.</p>
<p><span class="bold"><strong>Note:</strong></span> In this documentation, <code class="computeroutput">__function_type__</code> is a placeholder for a symbol that is specific to the implementation of this library.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>, <code class="computeroutput"><code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code></code>. </p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/tutorial.html" title="Tutorial"> Tutorial</a> section, <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>, <code class="computeroutput"><code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code></code>. </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

View File

@@ -35,19 +35,19 @@
<span class="keyword">class</span> <a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="comment">// <a class="link" href="overloaded_function.html#boost.overloaded_functionconstruct-copy-destruct">construct/copy/destruct</a></span>
<a class="link" href="overloaded_function.html#id313151-bb"><span class="identifier">overloaded_function</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<a class="link" href="overloaded_function.html#id259090-bb"><span class="identifier">overloaded_function</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span>
<span class="comment">// <a class="link" href="overloaded_function.html#id313082-bb">public member functions</a></span>
<span class="comment">// <a class="link" href="overloaded_function.html#id259020-bb">public member functions</a></span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a class="link" href="overloaded_function.html#id313084-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<a class="link" href="overloaded_function.html#id259023-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a class="link" href="overloaded_function.html#id313110-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<a class="link" href="overloaded_function.html#id259049-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id812550"></a><h2>Description</h2>
<a name="id820590"></a><h2>Description</h2>
<p>This function object aggregates together calls to functions of all the specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc which must have distinct function signatures from one another.</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
@@ -65,30 +65,30 @@
</p>
<p>In some cases, the <code class="computeroutput"><a class="link" href="make_overloaded_function.html" title="Function template make_overloaded_function">make_overloaded_function</a></code> function template can be useful to construct an overloaded function object without explicitly specifying the function types.</p>
<p>At least two distinct function types must be specified (because there is nothing to overload between one or zero functions). The maximum number of functions to overload is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code> configuration macro. The maximum number of function parameters for each of the specified function types is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code> configuration macro.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><a class="link" href="make_overloaded_function.html" title="Function template make_overloaded_function">make_overloaded_function</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code>, Boost.Function. </p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/tutorial.html" title="Tutorial"> Tutorial</a> section, <code class="computeroutput"><a class="link" href="make_overloaded_function.html" title="Function template make_overloaded_function">make_overloaded_function</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code>, Boost.Function. </p>
<div class="refsect2">
<a name="id812697"></a><h3>
<a name="id820738"></a><h3>
<a name="boost.overloaded_functionconstruct-copy-destruct"></a><code class="computeroutput">overloaded_function</code>
public
construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="id313151-bb"></a><span class="identifier">overloaded_function</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<pre class="literallayout"><a name="id259090-bb"></a><span class="identifier">overloaded_function</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre>Construct the overloaded function object. <p>Any function pointer, function reference, and monomorphic function object that can be converted to a <code class="computeroutput">boost::function</code> function object can be specified as parameter.</p>
<p><span class="bold"><strong>Note:</strong></span> Unfortunately, it is not possible to support polymorphic function objects (as explained <a href="http://lists.boost.org/Archives/boost/2012/03/191744.php" target="_top">here</a>). </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="id812834"></a><h3>
<a name="id313082-bb"></a><code class="computeroutput">overloaded_function</code> public member functions</h3>
<a name="id820874"></a><h3>
<a name="id259020-bb"></a><code class="computeroutput">overloaded_function</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a name="id313084-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<a name="id259023-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 1st template parameter. <p>This will in turn invoke the call operator of the 1st function passed to the constructor. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a name="id313110-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<a name="id259049-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 2nd template parameter. <p>This will in turn invoke the call operator of the 2nd function passed to the constructor.</p>
<p><span class="bold"><strong>Note:</strong></span> Similar call operators are present for all specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc (even if not exhaustively listed by this documentation). </p>
</li>

View File

@@ -21,9 +21,9 @@
<div class="spirit-nav">
<a accesskey="p" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a>
</div>
<div class="section boost_functional_overloadedfunction_Acknowledgments">
<div class="section boost_functional_overloadedfunction_acknowledgments">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_overloadedfunction.Acknowledgments"></a><a class="link" href="Acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
<a name="boost_functional_overloadedfunction.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
</h2></div></div></div>
<p>
Many thanks to Mathias Gaunard for suggesting to implement <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>

View File

@@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="prev" href="../index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="next" href="Tutorial.html" title="Tutorial">
<link rel="next" href="tutorial.html" title="Tutorial">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,24 +20,24 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Tutorial.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="../index.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_functional_overloadedfunction_Getting_Started">
<div class="section boost_functional_overloadedfunction_getting_started">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_overloadedfunction.Getting_Started"></a><a class="link" href="Getting_Started.html" title="Getting Started">Getting
<a name="boost_functional_overloadedfunction.getting_started"></a><a class="link" href="getting_started.html" title="Getting Started">Getting
Started</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.compilers_and_platforms">Compilers
<dt><span class="section"><a href="getting_started.html#boost_functional_overloadedfunction.getting_started.compilers_and_platforms">Compilers
and Platforms</a></span></dt>
<dt><span class="section"><a href="Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.installation">Installation</a></span></dt>
<dt><span class="section"><a href="getting_started.html#boost_functional_overloadedfunction.getting_started.installation">Installation</a></span></dt>
</dl></div>
<p>
This section explains how to setup a system to use this library.
</p>
<div class="section boost_functional_overloadedfunction_Getting_Started_compilers_and_platforms">
<div class="section boost_functional_overloadedfunction_getting_started_compilers_and_platforms">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_overloadedfunction.Getting_Started.compilers_and_platforms"></a><a class="link" href="Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.compilers_and_platforms" title="Compilers and Platforms">Compilers
<a name="boost_functional_overloadedfunction.getting_started.compilers_and_platforms"></a><a class="link" href="getting_started.html#boost_functional_overloadedfunction.getting_started.compilers_and_platforms" title="Compilers and Platforms">Compilers
and Platforms</a>
</h3></div></div></div>
<p>
@@ -60,9 +60,9 @@
for any special configuration that might be required for a specific compiler.
</p>
</div>
<div class="section boost_functional_overloadedfunction_Getting_Started_installation">
<div class="section boost_functional_overloadedfunction_getting_started_installation">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_overloadedfunction.Getting_Started.installation"></a><a class="link" href="Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.installation" title="Installation">Installation</a>
<a name="boost_functional_overloadedfunction.getting_started.installation"></a><a class="link" href="getting_started.html#boost_functional_overloadedfunction.getting_started.installation" title="Installation">Installation</a>
</h3></div></div></div>
<p>
This library is composed of header files only. Therefore there is no pre-compiled
@@ -89,7 +89,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Tutorial.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="../index.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="prev" href="Getting_Started.html" title="Getting Started">
<link rel="prev" href="getting_started.html" title="Getting Started">
<link rel="next" href="../reference.html" title="Reference">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,23 +20,23 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="Getting_Started.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="getting_started.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_functional_overloadedfunction_Tutorial">
<div class="section boost_functional_overloadedfunction_tutorial">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_overloadedfunction.Tutorial"></a><a class="link" href="Tutorial.html" title="Tutorial">Tutorial</a>
<a name="boost_functional_overloadedfunction.tutorial"></a><a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="Tutorial.html#boost_functional_overloadedfunction.Tutorial.overloading">Overloading</a></span></dt>
<dt><span class="section"><a href="Tutorial.html#boost_functional_overloadedfunction.Tutorial.without_function_types">Without
<dt><span class="section"><a href="tutorial.html#boost_functional_overloadedfunction.tutorial.overloading">Overloading</a></span></dt>
<dt><span class="section"><a href="tutorial.html#boost_functional_overloadedfunction.tutorial.without_function_types">Without
Function Types</a></span></dt>
</dl></div>
<p>
This section explains how to use this library.
</p>
<div class="section boost_functional_overloadedfunction_Tutorial_overloading">
<div class="section boost_functional_overloadedfunction_tutorial_overloading">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_overloadedfunction.Tutorial.overloading"></a><a class="link" href="Tutorial.html#boost_functional_overloadedfunction.Tutorial.overloading" title="Overloading">Overloading</a>
<a name="boost_functional_overloadedfunction.tutorial.overloading"></a><a class="link" href="tutorial.html#boost_functional_overloadedfunction.tutorial.overloading" title="Overloading">Overloading</a>
</h3></div></div></div>
<p>
Consider the following functions which have distinct signatures:
@@ -87,7 +87,7 @@
<p>
Then the relative function pointers, function references, or <a href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)" target="_top">monomorphic
function</a> objects are passed to the <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>
constructor matching the order of the specified template parameters. <sup>[<a name="boost_functional_overloadedfunction.Tutorial.overloading.f0" href="#ftn.boost_functional_overloadedfunction.Tutorial.overloading.f0" class="footnote">2</a>]</sup> In the above example, <code class="computeroutput"><span class="identifier">identity_s</span></code>
constructor matching the order of the specified template parameters. <sup>[<a name="boost_functional_overloadedfunction.tutorial.overloading.f0" href="#ftn.boost_functional_overloadedfunction.tutorial.overloading.f0" class="footnote">2</a>]</sup> In the above example, <code class="computeroutput"><span class="identifier">identity_s</span></code>
is passed as a function pointer (the function address is automatically taken
from the function name by the compiler), <code class="computeroutput"><span class="identifier">identity_i</span></code>
as a function reference, and <code class="computeroutput"><span class="identifier">identity_d</span></code>
@@ -95,14 +95,14 @@
</p>
<p>
All specified function types must have distinct parameters from one another
(so the overloaded calls can be resolved by this library). <sup>[<a name="boost_functional_overloadedfunction.Tutorial.overloading.f1" href="#ftn.boost_functional_overloadedfunction.Tutorial.overloading.f1" class="footnote">3</a>]</sup> In order to create an overloaded function object, it is necessary
(so the overloaded calls can be resolved by this library). <sup>[<a name="boost_functional_overloadedfunction.tutorial.overloading.f1" href="#ftn.boost_functional_overloadedfunction.tutorial.overloading.f1" class="footnote">3</a>]</sup> In order to create an overloaded function object, it is necessary
to specify at least two function types (because there is nothing to overload
between one or zero functions).
</p>
</div>
<div class="section boost_functional_overloadedfunction_Tutorial_without_function_types">
<div class="section boost_functional_overloadedfunction_tutorial_without_function_types">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_functional_overloadedfunction.Tutorial.without_function_types"></a><a class="link" href="Tutorial.html#boost_functional_overloadedfunction.Tutorial.without_function_types" title="Without Function Types">Without
<a name="boost_functional_overloadedfunction.tutorial.without_function_types"></a><a class="link" href="tutorial.html#boost_functional_overloadedfunction.tutorial.without_function_types" title="Without Function Types">Without
Function Types</a>
</h3></div></div></div>
<p>
@@ -189,7 +189,7 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.Tutorial.overloading.f0" href="#boost_functional_overloadedfunction.Tutorial.overloading.f0" class="para">2</a>] </sup>
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.tutorial.overloading.f0" href="#boost_functional_overloadedfunction.tutorial.overloading.f0" class="para">2</a>] </sup>
Function pointers are of the form <code class="literal"><span class="emphasis"><em>result-type </em></span></code><code class="computeroutput"><span class="special">(*)(</span></code><code class="literal"><span class="emphasis"><em>argument1-type</em></span></code><code class="computeroutput"><span class="special">,</span> <span class="special">...)</span></code> (the
C++ compiler is usually able to automatically promote a function name to
a function pointer in a context where a function pointer is expected even
@@ -204,7 +204,7 @@
Unfortunately, it is not possible to support polymorphic function objects
(see <a href="http://lists.boost.org/Archives/boost/2012/03/191744.php" target="_top">http://lists.boost.org/Archives/boost/2012/03/191744.php</a>).
</p></div>
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.Tutorial.overloading.f1" href="#boost_functional_overloadedfunction.Tutorial.overloading.f1" class="para">3</a>] </sup>
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.tutorial.overloading.f1" href="#boost_functional_overloadedfunction.tutorial.overloading.f1" class="para">3</a>] </sup>
Note that in C++ the function result type is not used for overload resolution
(to avoid making the overload resolution context dependent). Therefore,
at least one of the function parameters must be distinct for each specified
@@ -222,7 +222,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="Getting_Started.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="getting_started.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -5,7 +5,7 @@
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="next" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started">
<link rel="next" href="boost_functional_overloadedfunction/getting_started.html" title="Getting Started">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -17,7 +17,7 @@
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="boost_functional_overloadedfunction/Getting_Started.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="spirit-nav"><a accesskey="n" href="boost_functional_overloadedfunction/getting_started.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
@@ -36,18 +36,18 @@
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="index.html#boost_functional_overloadedfunction.Introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Getting_Started.html">Getting
<dt><span class="section"><a href="index.html#boost_functional_overloadedfunction.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/getting_started.html">Getting
Started</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.compilers_and_platforms">Compilers
<dt><span class="section"><a href="boost_functional_overloadedfunction/getting_started.html#boost_functional_overloadedfunction.getting_started.compilers_and_platforms">Compilers
and Platforms</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Getting_Started.html#boost_functional_overloadedfunction.Getting_Started.installation">Installation</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/getting_started.html#boost_functional_overloadedfunction.getting_started.installation">Installation</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Tutorial.html">Tutorial</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/tutorial.html">Tutorial</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Tutorial.html#boost_functional_overloadedfunction.Tutorial.overloading">Overloading</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Tutorial.html#boost_functional_overloadedfunction.Tutorial.without_function_types">Without
<dt><span class="section"><a href="boost_functional_overloadedfunction/tutorial.html#boost_functional_overloadedfunction.tutorial.overloading">Overloading</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/tutorial.html#boost_functional_overloadedfunction.tutorial.without_function_types">Without
Function Types</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="reference.html">Reference</a></span></dt>
@@ -55,15 +55,15 @@
<dt><span class="section"><a href="reference.html#header.boost.functional.overloaded_function_hpp">Header &lt;boost/functional/overloaded_function.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="reference.html#header.boost.functional.overloaded_function.config_hpp">Header &lt;boost/functional/overloaded_function/config.hpp&gt;</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="boost_functional_overloadedfunction/Acknowledgments.html">Acknowledgments</a></span></dt>
<dt><span class="section"><a href="boost_functional_overloadedfunction/acknowledgments.html">Acknowledgments</a></span></dt>
</dl>
</div>
<p>
This library allows to overload different functions into a single function object.
</p>
<div class="section boost_functional_overloadedfunction_Introduction">
<div class="section boost_functional_overloadedfunction_introduction">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_functional_overloadedfunction.Introduction"></a><a class="link" href="index.html#boost_functional_overloadedfunction.Introduction" title="Introduction">Introduction</a>
<a name="boost_functional_overloadedfunction.introduction"></a><a class="link" href="index.html#boost_functional_overloadedfunction.introduction" title="Introduction">Introduction</a>
</h2></div></div></div>
<p>
Consider the following functions which have distinct signatures:
@@ -84,7 +84,7 @@
<p>
Instead of calling them using their separate names (here <code class="computeroutput"><span class="identifier">BOOST_TEST</span></code>
is equivalent to <code class="computeroutput"><span class="identifier">assert</span></code>):
<sup>[<a name="boost_functional_overloadedfunction.Introduction.f0" href="#ftn.boost_functional_overloadedfunction.Introduction.f0" class="footnote">1</a>]</sup>
<sup>[<a name="boost_functional_overloadedfunction.introduction.f0" href="#ftn.boost_functional_overloadedfunction.introduction.f0" class="footnote">1</a>]</sup>
</p>
<p>
</p>
@@ -125,7 +125,7 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.Introduction.f0" href="#boost_functional_overloadedfunction.Introduction.f0" class="para">1</a>] </sup>
<div class="footnote"><p><sup>[<a id="ftn.boost_functional_overloadedfunction.introduction.f0" href="#boost_functional_overloadedfunction.introduction.f0" class="para">1</a>] </sup>
In most of the examples presented in this documentation, the Boost.Detail/LightweightTest
(<code class="literal">boost/detail/lightweight_test.hpp</code>) macro <code class="computeroutput"><span class="identifier">BOOST_TEST</span></code> is used to check correctness
conditions (conceptually similar to <code class="computeroutput"><span class="identifier">assert</span></code>).
@@ -138,10 +138,10 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: April 13, 2012 at 00:59:44 GMT</small></p></td>
<td align="left"><p><small>Last revised: April 28, 2012 at 02:19:13 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="boost_functional_overloadedfunction/Getting_Started.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="spirit-nav"><a accesskey="n" href="boost_functional_overloadedfunction/getting_started.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a></div>
</body>
</html>

View File

@@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="up" href="index.html" title="Chapter&#160;1.&#160;Boost.Functional/OverloadedFunction 1.0.0">
<link rel="prev" href="boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">
<link rel="prev" href="boost_functional_overloadedfunction/tutorial.html" title="Tutorial">
<link rel="next" href="boost/overloaded_function.html" title="Class template overloaded_function">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_functional_overloadedfunction/Tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost/overloaded_function.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="boost_functional_overloadedfunction/tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost/overloaded_function.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section reference">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -60,7 +60,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_functional_overloadedfunction/Tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost/overloaded_function.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="boost_functional_overloadedfunction/tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost/overloaded_function.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>