]> git.lyx.org Git - lyx.git/blob - boost/boost/preprocessor/list/filter.hpp
major boost 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>Uses</h3>
34 <ul>
35   <li>BOOST_PP_WHILE() (see for explanation of the D parameter)</li>
36   <li>BOOST_PP_LIST_FOLD_RIGHT()</li>
37 </ul>
38
39 <h3>Test</h3>
40 <ul>
41   <li><a href="../../test/list_test.cpp">list_test.cpp</a></li>
42 </ul>
43 */
44 #define BOOST_PP_LIST_FILTER(PRED,DATA,LIST) BOOST_PP_LIST_FILTER_D(0,PRED,DATA,LIST)
45
46 /** <p>Can be used inside BOOST_PP_WHILE().</p> */
47 #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))))
48 #if !defined(BOOST_NO_COMPILER_CONFIG) && defined(__MWERKS__)
49 #  define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE3_ELEM1 P,H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE_ELEM(3,2,P)))
50 #elif !defined(BOOST_NO_COMPILER_CONFIG) && defined(_MSC_VER)
51 #  define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE3_ELEM1 P,BOOST_PP_IF(BOOST_PP_TUPLE3_ELEM0 P(D,BOOST_PP_TUPLE3_ELEM1 P,H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE3_ELEM2 P))
52 #else
53 #  define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE3_ELEM0 P,BOOST_PP_TUPLE3_ELEM1 P,BOOST_PP_IF(BOOST_PP_TUPLE3_ELEM0 P(D,BOOST_PP_TUPLE3_ELEM1 P,H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE3_ELEM2 P))
54 #endif
55 #endif