File indexing completed on 2025-01-18 09:28:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ALGORITHM_ONE_OF_HPP
0013 #define BOOST_ALGORITHM_ONE_OF_HPP
0014
0015 #include <boost/config.hpp>
0016 #include <boost/range/begin.hpp>
0017 #include <boost/range/end.hpp>
0018
0019 #include <boost/algorithm/cxx11/none_of.hpp>
0020
0021
0022 namespace boost { namespace algorithm {
0023
0024
0025
0026
0027
0028
0029
0030
0031 template<typename InputIterator, typename Predicate>
0032 BOOST_CXX14_CONSTEXPR bool one_of ( InputIterator first, InputIterator last, Predicate p )
0033 {
0034
0035 for (; first != last; ++first)
0036 if (p(*first))
0037 break;
0038
0039 if (first == last)
0040 return false;
0041 return boost::algorithm::none_of (++first, last, p);
0042 }
0043
0044
0045
0046
0047
0048
0049
0050 template<typename Range, typename Predicate>
0051 BOOST_CXX14_CONSTEXPR bool one_of ( const Range &r, Predicate p )
0052 {
0053 return boost::algorithm::one_of ( boost::begin (r), boost::end (r), p );
0054 }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 template<typename InputIterator, typename V>
0065 BOOST_CXX14_CONSTEXPR bool one_of_equal ( InputIterator first, InputIterator last, const V &val )
0066 {
0067
0068 for (; first != last; ++first)
0069 if (*first == val)
0070 break;
0071
0072 if (first == last)
0073 return false;
0074 return boost::algorithm::none_of_equal (++first, last, val);
0075 }
0076
0077
0078
0079
0080
0081
0082
0083 template<typename Range, typename V>
0084 BOOST_CXX14_CONSTEXPR bool one_of_equal ( const Range &r, const V &val )
0085 {
0086 return boost::algorithm::one_of_equal ( boost::begin (r), boost::end (r), val );
0087 }
0088
0089 }}
0090
0091 #endif