Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:47

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Hartmut Kaiser
0003     Copyright (c) 2001-2011 Joel de Guzman
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(BOOST_SPIRIT_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM)
0009 #define BOOST_SPIRIT_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM
0010 
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014 
0015 #include <boost/spirit/home/support/algorithm/any_if.hpp>
0016 #include <boost/spirit/home/support/algorithm/any_ns_so.hpp>
0017 
0018 namespace boost { namespace spirit
0019 {
0020     ///////////////////////////////////////////////////////////////////////////
0021     //  This is a special version for a binary fusion::any. The predicate
0022     //  is used to decide whether to advance the second iterator or not.
0023     //  This is needed for sequences containing components with unused
0024     //  attributes. The second iterator is advanced only if the attribute
0025     //  of the corresponding component iterator is not unused.
0026     //
0027     //  This is a non-short circuiting (ns) strict order (so) version of the
0028     //  any_if algorithm.
0029     ///////////////////////////////////////////////////////////////////////////
0030     namespace detail
0031     {
0032         template <
0033             typename Pred, typename First1, typename Last1, typename First2
0034           , typename Last2, typename F
0035         >
0036         inline bool
0037         any_if_ns_so(First1 const&, First2 const&, Last1 const&, Last2 const&
0038           , F const&, mpl::true_)
0039         {
0040             return false;
0041         }
0042 
0043         template <
0044             typename Pred, typename First1, typename Last1, typename First2
0045           , typename Last2, typename F
0046         >
0047         inline bool
0048         any_if_ns_so(First1 const& first1, First2 const& first2
0049           , Last1 const& last1, Last2 const& last2, F& f, mpl::false_)
0050         {
0051             typename result_of::attribute_value<First1, First2, Last2, Pred>::type
0052                 attribute = spirit::detail::attribute_value<Pred, First1, Last2>(first2);
0053 
0054             bool head = f(*first1, attribute);
0055             bool tail =
0056                 detail::any_if_ns_so<Pred>(
0057                     fusion::next(first1)
0058                   , attribute_next<Pred, First1, Last2>(first2)
0059                   , last1, last2
0060                   , f
0061                   , fusion::result_of::equal_to<
0062                         typename fusion::result_of::next<First1>::type, Last1>());
0063             return head || tail;
0064         }
0065     }
0066 
0067     template <typename Pred, typename Sequence1, typename Sequence2, typename F>
0068     inline bool
0069     any_if_ns_so(Sequence1 const& seq1, Sequence2& seq2, F f, Pred)
0070     {
0071         return detail::any_if_ns_so<Pred>(
0072                 fusion::begin(seq1), fusion::begin(seq2)
0073               , fusion::end(seq1), fusion::end(seq2)
0074               , f
0075               , fusion::result_of::equal_to<
0076                     typename fusion::result_of::begin<Sequence1>::type
0077                   , typename fusion::result_of::end<Sequence1>::type>());
0078     }
0079 
0080     template <typename Pred, typename Sequence, typename F>
0081     inline bool
0082     any_if_ns_so(Sequence const& seq, unused_type const, F f, Pred)
0083     {
0084         return detail::any_ns_so(
0085                 fusion::begin(seq)
0086               , fusion::end(seq)
0087               , f
0088               , fusion::result_of::equal_to<
0089                     typename fusion::result_of::begin<Sequence>::type
0090                   , typename fusion::result_of::end<Sequence>::type>());
0091     }
0092 
0093 }}
0094 
0095 #endif
0096