Files
boost_preprocessor/doc/reference/list_fold_left.htm
Vesa Karvonen 9f9048e805 Automatic recursion
[SVN r14100]
2002-06-07 13:04:18 +00:00

104 lines
3.8 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../../boost.css">
<title>Boost.Preprocessor - Reference</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Header &lt;<a href="../../../../boost/preprocessor/list/fold_left.hpp">boost/preprocessor/list/fold_left.hpp</a>&gt;</h2>
</td>
</tr>
</table>
<hr>
<a href="list_first_n.htm">Prev</a> <a href="list_fold_left_2nd.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<h3><a name="BOOST_PP_LIST_FOLD_LEFT">#define BOOST_PP_LIST_FOLD_LEFT</a>(OP,STATE,LIST)</h3>
<p>Iterates <code>OP(D,STATE,X)</code> for each element <code>X</code> of the
list <code>LIST</code> (from the left or the start of the list).</p>
<p>In other words, expands to:</p>
<pre>
OP
( D
, ... OP(D, OP(D,STATE,<a href="list_at.htm#BOOST_PP_LIST_AT">BOOST_PP_LIST_AT</a>(LIST,0)), <a href="list_at.htm#BOOST_PP_LIST_AT">BOOST_PP_LIST_AT</a>(LIST,1)) ...
, <a href="list_at.htm#BOOST_PP_LIST_AT">BOOST_PP_LIST_AT</a>(LIST,<a href="dec.htm#BOOST_PP_DEC">BOOST_PP_DEC</a>(<a href="list_size.htm#BOOST_PP_LIST_SIZE">BOOST_PP_LIST_SIZE</a>(LIST))
)
</pre>
<p>For example,</p>
<pre>
#define TEST(D,STATE,X) <a href="cat.htm#BOOST_PP_CAT">BOOST_PP_CAT</a>(STATE,X)
<a href="list_fold_left.htm#BOOST_PP_LIST_FOLD_LEFT">BOOST_PP_LIST_FOLD_LEFT</a>(TEST,_,<a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(3,(A,B,C)))
</pre>
<p>expands to:</p>
<pre>
_ABC
</pre>
<h3>Note</h3>
<ul>
<li>Folding, or accumulation, is a very general pattern of computation.
Most list operations can be implemented in terms of folding.</li>
</ul>
<h3>See</h3>
<ul>
<li><a href="list_fold_right.htm#BOOST_PP_LIST_FOLD_RIGHT">BOOST_PP_LIST_FOLD_RIGHT</a>()</li>
</ul>
<h3>Test</h3>
<ul>
<li><a href="../../test/list_test.cpp">list_test.cpp</a></li>
</ul>
<hr>
<h3><a name="BOOST_PP_LIST_FOLD_LEFT_D">#define BOOST_PP_LIST_FOLD_LEFT_D</a>(D,OP,STATE,LIST)</h3>
<p>Can be used inside <a href="while.htm#BOOST_PP_WHILE">BOOST_PP_WHILE</a>() (see for an explanation of the D parameter).</p>
<h3>Note</h3>
<ul>
<li><a href="list_fold_left.htm#BOOST_PP_LIST_FOLD_LEFT_D">BOOST_PP_LIST_FOLD_LEFT_D</a>() implements automatic recursion. You
can use a fold in the OP macro.</li>
</ul>
<hr>
<h3><a name="BOOST_PP_LIST_FOLD_LEFT_2ND">#define BOOST_PP_LIST_FOLD_LEFT_2ND</a></h3>
<p>Obsolete, just use <a href="list_fold_left.htm#BOOST_PP_LIST_FOLD_LEFT">BOOST_PP_LIST_FOLD_LEFT</a>().</p>
<hr>
<h3><a name="BOOST_PP_LIST_FOLD_LEFT_2ND_D">#define BOOST_PP_LIST_FOLD_LEFT_2ND_D</a></h3>
<p>Obsolete, just use <a href="list_fold_left.htm#BOOST_PP_LIST_FOLD_LEFT_D">BOOST_PP_LIST_FOLD_LEFT_D</a>().</p>
<hr>
<a href="list_first_n.htm">Prev</a> <a href="list_fold_left_2nd.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
<p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
"as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</p>
</body></html>