1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2012 Eric Niebler
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)
-->
<header name="boost/proto/transform/fold.hpp">
<para>Contains definition of the
<computeroutput>
<classname alt="boost::proto::fold">proto::fold<></classname>
</computeroutput> and
<computeroutput>
<classname alt="boost::proto::reverse_fold">proto::reverse_fold<></classname>
</computeroutput>
transforms.</para>
<namespace name="boost">
<namespace name="proto">
<struct name="fold">
<template>
<template-type-parameter name="Sequence"/>
<template-type-parameter name="State0"/>
<template-type-parameter name="Fun"/>
</template>
<inherit>
<classname>proto::transform</classname>< fold<Sequence, State0, Fun> ></inherit>
<purpose>A <conceptname>PrimitiveTransform</conceptname> that invokes the
<computeroutput>fusion::fold<></computeroutput> algorithm to accumulate a value.</purpose>
<description>
<para>
For the complete description of the behavior of the <computeroutput>proto::fold<></computeroutput>
transform, see the documentation for the nested <computeroutput>
<classname>proto::fold::impl<></classname>
</computeroutput> class template.
</para>
</description>
<struct name="impl">
<template>
<template-type-parameter name="Expr"/>
<template-type-parameter name="State"/>
<template-type-parameter name="Data"/>
</template>
<inherit><classname>proto::transform_impl</classname>< Expr, State, Data ></inherit>
<typedef name="X">
<purpose>For exposition only</purpose>
<type><classname>when</classname><<classname>_</classname>, Sequence></type>
</typedef>
<typedef name="Y">
<purpose>For exposition only</purpose>
<type><classname>when</classname><<classname>_</classname>, State0></type>
</typedef>
<typedef name="seq">
<purpose>A Fusion sequence, for exposition only</purpose>
<type>typename boost::result_of<X(Expr, State, Data)>::type</type>
</typedef>
<typedef name="state0">
<purpose>An initial state for the fold, for exposition only</purpose>
<type>typename boost::result_of<Y(Expr, State, Data)>::type</type>
</typedef>
<typedef name="fun">
<purpose><computeroutput>fun(d)(s,e) == when<_,Fun>()(e,s,d)</computeroutput></purpose>
<type><emphasis>unspecified</emphasis></type>
</typedef>
<typedef name="result_type">
<type>typename fusion::result_of::fold<seq, state0, fun>::type</type>
</typedef>
<method-group name="public member functions">
<method name="operator()" cv="const">
<type>result_type</type>
<parameter name="expr">
<paramtype>typename impl::expr_param</paramtype>
<description>
<para>The current expression </para>
</description>
</parameter>
<parameter name="state">
<paramtype>typename impl::state_param</paramtype>
<description>
<para>The current state </para>
</description>
</parameter>
<parameter name="data">
<paramtype>typename impl::data_param</paramtype>
<description>
<para>An arbitrary data </para>
</description>
</parameter>
<description>
<para>
Let <computeroutput>seq</computeroutput> be
<computeroutput><classname>when</classname><<classname>_</classname>, Sequence>()(expr, state, data)</computeroutput>,
let <computeroutput>state0</computeroutput> be
<computeroutput><classname>when</classname><<classname>_</classname>, State0>()(expr, state, data)</computeroutput>,
and let <computeroutput>fun(data)</computeroutput> be an object such that
<computeroutput>fun(data)(state, expr)</computeroutput> is equivalent to
<computeroutput><classname>when</classname><<classname>_</classname>, Fun>()(expr, state, data)</computeroutput>. Then,
this function returns <computeroutput>fusion::fold(seq, state0, fun(data))</computeroutput>.
</para>
</description>
</method>
</method-group>
</struct>
</struct>
<struct name="reverse_fold">
<template>
<template-type-parameter name="Sequence"/>
<template-type-parameter name="State0"/>
<template-type-parameter name="Fun"/>
</template>
<inherit><classname>proto::fold</classname>< <classname>proto::_reverse</classname>(Sequence), State0, Fun ></inherit>
<purpose>
A <conceptname>PrimitiveTransform</conceptname> that is the same as the <computeroutput><classname>proto::fold<></classname></computeroutput>
transform, except that it folds back-to-front instead of front-to-back. It uses the
<computeroutput>
<classname>proto::_reverse</classname>
</computeroutput> callable <conceptname>PolymorphicFunctionObject</conceptname> to create a
<computeroutput>fusion::reverse_view<></computeroutput> of the sequence before invoking
<computeroutput>fusion::fold<></computeroutput>.
</purpose>
</struct>
</namespace>
</namespace>
</header>
|