]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/util/combine_if.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / util / combine_if.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
4
5 // This file was modified by Oracle on 2015-2020.
6 // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
11 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
12 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
13
14 // Use, modification and distribution is subject to the Boost Software License,
15 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
17
18 #ifndef BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP
19 #define BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP
20
21 #include <boost/config/pragma_message.hpp>
22 #if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
23 BOOST_PRAGMA_MESSAGE("This header is deprecated.")
24 #endif
25
26 #include <boost/mpl/bind.hpp>
27 #include <boost/mpl/fold.hpp>
28 #include <boost/mpl/if.hpp>
29 #include <boost/mpl/insert.hpp>
30 #include <boost/mpl/pair.hpp>
31 #include <boost/mpl/placeholders.hpp>
32 #include <boost/mpl/set.hpp>
33
34 namespace boost { namespace geometry
35 {
36
37 namespace util
38 {
39
40
41 /*!
42 \brief Meta-function to generate all the combination of pairs of types
43 from a given sequence Sequence except those that does not satisfy the
44 predicate Pred
45 \ingroup utility
46 \par Example
47 \code
48 typedef boost::mpl::vector<boost::mpl::int_<0>, boost::mpl::int_<1> > types;
49 typedef combine_if<types, types, always<true_> >::type combinations;
50 typedef boost::mpl::vector<
51 pair<boost::mpl::int_<1>, boost::mpl::int_<1> >,
52 pair<boost::mpl::int_<1>, boost::mpl::int_<0> >,
53 pair<boost::mpl::int_<0>, boost::mpl::int_<1> >,
54 pair<boost::mpl::int_<0>, boost::mpl::int_<0> >
55 > result_types;
56
57 BOOST_MPL_ASSERT(( boost::mpl::equal<combinations, result_types> ));
58 \endcode
59 */
60 template <typename Sequence1, typename Sequence2, typename Pred>
61 struct combine_if
62 {
63 struct combine
64 {
65 template <typename Result, typename T>
66 struct apply
67 {
68 typedef typename boost::mpl::fold<Sequence2, Result,
69 boost::mpl::if_
70 <
71 boost::mpl::bind
72 <
73 typename boost::mpl::lambda<Pred>::type,
74 T,
75 boost::mpl::_2
76 >,
77 boost::mpl::insert
78 <
79 boost::mpl::_1, boost::mpl::pair<T, boost::mpl::_2>
80 >,
81 boost::mpl::_1
82 >
83 >::type type;
84 };
85 };
86
87 typedef typename boost::mpl::fold
88 <
89 Sequence1, boost::mpl::set0<>, combine
90 >::type type;
91 };
92
93
94 } // namespace util
95
96 }} // namespace boost::geometry
97
98 #endif // BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP