Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:42:16

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
0004 
0005 // This file was modified by Oracle on 2015-2020.
0006 // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
0007 
0008 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP
0019 #define BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP
0020 
0021 #include <boost/config/pragma_message.hpp>
0022 #if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
0023 BOOST_PRAGMA_MESSAGE("This header is deprecated.")
0024 #endif
0025 
0026 #include <boost/mpl/bind.hpp>
0027 #include <boost/mpl/fold.hpp>
0028 #include <boost/mpl/if.hpp>
0029 #include <boost/mpl/insert.hpp>
0030 #include <boost/mpl/pair.hpp>
0031 #include <boost/mpl/placeholders.hpp>
0032 #include <boost/mpl/set.hpp>
0033 
0034 namespace boost { namespace geometry
0035 {
0036 
0037 namespace util
0038 {
0039 
0040 
0041 /*!
0042     \brief Meta-function to generate all the combination of pairs of types
0043         from a given sequence Sequence except those that does not satisfy the
0044         predicate Pred
0045     \ingroup utility
0046     \par Example
0047     \code
0048         typedef boost::mpl::vector<boost::mpl::int_<0>, boost::mpl::int_<1> > types;
0049         typedef combine_if<types, types, always<true_> >::type combinations;
0050         typedef boost::mpl::vector<
0051             pair<boost::mpl::int_<1>, boost::mpl::int_<1> >,
0052             pair<boost::mpl::int_<1>, boost::mpl::int_<0> >,
0053             pair<boost::mpl::int_<0>, boost::mpl::int_<1> >,
0054             pair<boost::mpl::int_<0>, boost::mpl::int_<0> >
0055         > result_types;
0056 
0057         BOOST_MPL_ASSERT(( boost::mpl::equal<combinations, result_types> ));
0058     \endcode
0059 */
0060 template <typename Sequence1, typename Sequence2, typename Pred>
0061 struct combine_if
0062 {
0063     struct combine
0064     {
0065         template <typename Result, typename T>
0066         struct apply
0067         {
0068             typedef typename boost::mpl::fold<Sequence2, Result,
0069                 boost::mpl::if_
0070                 <
0071                     boost::mpl::bind
0072                         <
0073                             typename boost::mpl::lambda<Pred>::type,
0074                             T,
0075                             boost::mpl::_2
0076                         >,
0077                     boost::mpl::insert
0078                         <
0079                             boost::mpl::_1, boost::mpl::pair<T, boost::mpl::_2>
0080                         >,
0081                     boost::mpl::_1
0082                 >
0083             >::type type;
0084         };
0085     };
0086 
0087     typedef typename boost::mpl::fold
0088         <
0089             Sequence1, boost::mpl::set0<>, combine
0090         >::type type;
0091 };
0092 
0093 
0094 } // namespace util
0095 
0096 }} // namespace boost::geometry
0097 
0098 #endif // BOOST_GEOMETRY_UTIL_COMBINE_IF_HPP