Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //  Copyright Neil Groves 2009. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
0008 //
0009 #ifndef BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
0011 
0012 #include <boost/concept_check.hpp>
0013 #include <boost/range/begin.hpp>
0014 #include <boost/range/end.hpp>
0015 #include <boost/range/concepts.hpp>
0016 #include <boost/range/detail/range_return.hpp>
0017 #include <algorithm>
0018 
0019 namespace boost
0020 {
0021     namespace range
0022     {
0023 
0024 /// \brief template function find_end
0025 ///
0026 /// range-based version of the find_end std algorithm
0027 ///
0028 /// \pre ForwardRange1 is a model of the ForwardRangeConcept
0029 /// \pre ForwardRange2 is a model of the ForwardRangeConcept
0030 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0031 template< class ForwardRange1, class ForwardRange2 >
0032 inline BOOST_DEDUCED_TYPENAME disable_if<
0033     is_const<ForwardRange1>,
0034     BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type
0035 >::type
0036 find_end(ForwardRange1 & rng1, const ForwardRange2& rng2)
0037 {
0038     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0039     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0040 
0041     return std::find_end(boost::begin(rng1),boost::end(rng1),
0042                          boost::begin(rng2),boost::end(rng2));
0043 }
0044 
0045 /// \overload
0046 template< class ForwardRange1, class ForwardRange2 >
0047 inline BOOST_DEDUCED_TYPENAME range_iterator< const ForwardRange1 >::type
0048 find_end(const ForwardRange1 & rng1, const ForwardRange2& rng2)
0049 {
0050     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0051     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0052 
0053     return std::find_end(boost::begin(rng1),boost::end(rng1),
0054                          boost::begin(rng2),boost::end(rng2));
0055 }
0056 
0057 /// \overload
0058 template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
0059 inline BOOST_DEDUCED_TYPENAME disable_if<
0060     is_const<ForwardRange1>,
0061     BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
0062 >::type
0063 find_end(ForwardRange1 & rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0064 {
0065     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0066     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0067 
0068     return std::find_end(boost::begin(rng1),boost::end(rng1),
0069                          boost::begin(rng2),boost::end(rng2),pred);
0070 }
0071 
0072 /// \overload
0073 template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
0074 inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
0075 find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0076 {
0077     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0078     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0079 
0080     return std::find_end(boost::begin(rng1),boost::end(rng1),
0081                          boost::begin(rng2),boost::end(rng2),pred);
0082 }
0083 
0084 /// \overload
0085 template< range_return_value re, class ForwardRange1, class ForwardRange2 >
0086 inline BOOST_DEDUCED_TYPENAME disable_if<
0087     is_const<ForwardRange1>,
0088     BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
0089 >::type
0090 find_end(ForwardRange1& rng1, const ForwardRange2& rng2)
0091 {
0092     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0093     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0094 
0095     return range_return<ForwardRange1,re>::
0096         pack(std::find_end(boost::begin(rng1), boost::end(rng1),
0097                            boost::begin(rng2), boost::end(rng2)),
0098              rng1);
0099 }
0100 
0101 /// \overload
0102 template< range_return_value re, class ForwardRange1, class ForwardRange2 >
0103 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
0104 find_end(const ForwardRange1& rng1, const ForwardRange2& rng2)
0105 {
0106     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0107     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0108 
0109     return range_return<const ForwardRange1,re>::
0110         pack(std::find_end(boost::begin(rng1), boost::end(rng1),
0111                            boost::begin(rng2), boost::end(rng2)),
0112              rng1);
0113 }
0114 
0115 /// \overload
0116 template< range_return_value re, class ForwardRange1, class ForwardRange2,
0117           class BinaryPredicate >
0118 inline BOOST_DEDUCED_TYPENAME disable_if<
0119     is_const<ForwardRange1>,
0120     BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
0121 >::type
0122 find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0123 {
0124     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0125     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0126 
0127     return range_return<ForwardRange1,re>::
0128         pack(std::find_end(boost::begin(rng1), boost::end(rng1),
0129                            boost::begin(rng2), boost::end(rng2), pred),
0130              rng1);
0131 }
0132 
0133 /// \overload
0134 template< range_return_value re, class ForwardRange1, class ForwardRange2,
0135           class BinaryPredicate >
0136 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
0137 find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0138 {
0139     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0140     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0141 
0142     return range_return<const ForwardRange1,re>::
0143         pack(std::find_end(boost::begin(rng1), boost::end(rng1),
0144                            boost::begin(rng2), boost::end(rng2), pred),
0145              rng1);
0146 }
0147 
0148     } // namespace range
0149     using range::find_end;
0150 } // namespace boost
0151 
0152 #endif // include guard