]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright Edward Diener 2015 | |
3 | // Use, modification and distribution are subject to the Boost Software License, | |
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt). | |
6 | ||
7 | #if !defined(BOOST_VMD_TUPLE_REMOVE_HPP) | |
8 | #define BOOST_VMD_TUPLE_REMOVE_HPP | |
9 | ||
10 | #include <boost/vmd/detail/setup.hpp> | |
11 | ||
12 | #if BOOST_PP_VARIADICS | |
13 | ||
14 | #include <boost/preprocessor/comparison/equal.hpp> | |
15 | #include <boost/preprocessor/control/iif.hpp> | |
16 | #include <boost/preprocessor/logical/bitand.hpp> | |
17 | #include <boost/preprocessor/tuple/remove.hpp> | |
18 | #include <boost/preprocessor/tuple/size.hpp> | |
19 | #include <boost/vmd/empty.hpp> | |
20 | ||
21 | /* | |
22 | ||
23 | The succeeding comments in this file are in doxygen format. | |
24 | ||
25 | */ | |
26 | ||
27 | /** \file | |
28 | */ | |
29 | ||
30 | /** \def BOOST_VMD_TUPLE_REMOVE(tuple,index) | |
31 | ||
32 | \brief removes an element from a tuple. | |
33 | ||
34 | tuple = tuple from which an element is to be removed. | |
35 | index = The zero-based position in tuple of the element to be removed. | |
36 | ||
37 | If index is greater or equal to the tuple size the result is undefined. | |
38 | If the tuple is a single element and the index is 0 the result is an empty tuple. | |
39 | Otherwise the result is a tuple after removing the index element. | |
40 | */ | |
41 | ||
42 | #define BOOST_VMD_TUPLE_REMOVE(tuple,index) \ | |
43 | BOOST_PP_IIF \ | |
44 | ( \ | |
45 | BOOST_PP_BITAND \ | |
46 | ( \ | |
47 | BOOST_PP_EQUAL(index,0), \ | |
48 | BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1) \ | |
49 | ), \ | |
50 | BOOST_VMD_EMPTY, \ | |
51 | BOOST_PP_TUPLE_REMOVE \ | |
52 | ) \ | |
53 | (tuple,index) \ | |
54 | /**/ | |
55 | ||
56 | /** \def BOOST_VMD_TUPLE_REMOVE_D(d,tuple,index) | |
57 | ||
58 | \brief removes an element from a tuple. It reenters BOOST_PP_WHILE with maximum efficiency. | |
59 | ||
60 | d = The next available BOOST_PP_WHILE iteration. | |
61 | tuple = tuple from which an element is to be removed. | |
62 | index = The zero-based position in tuple of the element to be removed. | |
63 | ||
64 | If index is greater or equal to the tuple size the result is undefined. | |
65 | If the tuple is a single element and the index is 0 the result is an empty tuple. | |
66 | Otherwise the result is a tuple after removing the index element. | |
67 | */ | |
68 | ||
69 | #define BOOST_VMD_TUPLE_REMOVE_D(d,tuple,index) \ | |
70 | BOOST_PP_IIF \ | |
71 | ( \ | |
72 | BOOST_PP_BITAND \ | |
73 | ( \ | |
74 | BOOST_PP_EQUAL_D(d,index,0), \ | |
75 | BOOST_PP_EQUAL_D(d,BOOST_PP_TUPLE_SIZE(tuple),1) \ | |
76 | ), \ | |
77 | BOOST_VMD_EMPTY, \ | |
78 | BOOST_PP_TUPLE_REMOVE_D \ | |
79 | ) \ | |
80 | (d,tuple,index) \ | |
81 | /**/ | |
82 | ||
83 | #endif /* BOOST_PP_VARIADICS */ | |
84 | #endif /* BOOST_VMD_TUPLE_REMOVE_HPP */ |