]> git.lyx.org Git - lyx.git/blob - boost/boost/preprocessor/list/filter.hpp
update
[lyx.git] / boost / boost / preprocessor / list / filter.hpp
1 #ifndef BOOST_PREPROCESSOR_LIST_FILTER_HPP
2 #define BOOST_PREPROCESSOR_LIST_FILTER_HPP
3
4 /* Copyright (C) 2001
5  * Housemarque Oy
6  * http://www.housemarque.com
7  *
8  * Permission to copy, use, modify, sell and distribute this software is
9  * granted provided this copyright notice appears in all copies. This
10  * software is provided "as is" without express or implied warranty, and
11  * with no claim as to its suitability for any purpose.
12  *
13  * See http://www.boost.org for most recent version.
14  */
15
16 #include <boost/preprocessor/list/fold_right.hpp>
17
18 /** <p>Expands to a list containing all the elements <code>X</code> of the list
19 for which <code>PRED(D,DATA,X)</code> is true.</p>
20
21 <p>For example,</p>
22
23 <pre>
24 BOOST_PP_LIST_FILTER(BOOST_PP_NOT_EQUAL_D,2,BOOST_PP_TUPLE_TO_LIST(3,(1,2,3)))
25 </pre>
26
27 <p>expands to the same as:</p>
28
29 <pre>
30 BOOST_PP_TUPLE_TO_LIST(2,(1,3))
31 </pre>
32
33 <h3>Test</h3>
34 <ul>
35   <li><a href="../../test/list_test.cpp">list_test.cpp</a></li>
36 </ul>
37 */
38 #define BOOST_PP_LIST_FILTER(PRED,DATA,LIST) BOOST_PP_LIST_FILTER_D(0,PRED,DATA,LIST)
39
40 /** <p>Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).</p> */
41 #define BOOST_PP_LIST_FILTER_D(D,PRED,DATA,LIST) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_FILTER_F,LIST,(PRED,DATA,(_,_,0))))
42
43 #define BOOST_PP_LIST_FILTER_F(D,X,PDR) (BOOST_PP_TUPLE_ELEM(3,0,PDR),BOOST_PP_TUPLE_ELEM(3,1,PDR),BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(3,0,PDR)(D,BOOST_PP_TUPLE_ELEM(3,1,PDR),X),BOOST_PP_LIST_CONS,BOOST_PP_IF1)(X,BOOST_PP_TUPLE_ELEM(3,2,PDR)))
44 #endif