| 1 | /* |
| 2 | Copyright (c) Marshall Clow 2011-2012. |
| 3 | |
| 4 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | */ |
| 7 | |
| 8 | /// \file find_if_not.hpp |
| 9 | /// \brief Find the first element in a sequence that does not satisfy a predicate. |
| 10 | /// \author Marshall Clow |
| 11 | |
| 12 | #ifndef BOOST_ALGORITHM_FIND_IF_NOT_HPP |
| 13 | #define BOOST_ALGORITHM_FIND_IF_NOT_HPP |
| 14 | |
| 15 | #include <boost/config.hpp> |
| 16 | #include <boost/range/begin.hpp> |
| 17 | #include <boost/range/end.hpp> |
| 18 | |
| 19 | namespace boost { namespace algorithm { |
| 20 | |
| 21 | /// \fn find_if_not(InputIterator first, InputIterator last, Predicate p) |
| 22 | /// \brief Finds the first element in the sequence that does not satisfy the predicate. |
| 23 | /// \return The iterator pointing to the desired element. |
| 24 | /// |
| 25 | /// \param first The start of the input sequence |
| 26 | /// \param last One past the end of the input sequence |
| 27 | /// \param p A predicate for testing the elements of the range |
| 28 | /// \note This function is part of the C++2011 standard library. |
| 29 | template<typename InputIterator, typename Predicate> |
| 30 | BOOST_CXX14_CONSTEXPR InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p ) |
| 31 | { |
| 32 | for ( ; first != last; ++first ) |
| 33 | if ( !p(*first)) |
| 34 | break; |
| 35 | return first; |
| 36 | } |
| 37 | |
| 38 | /// \fn find_if_not ( const Range &r, Predicate p ) |
| 39 | /// \brief Finds the first element in the sequence that does not satisfy the predicate. |
| 40 | /// \return The iterator pointing to the desired element. |
| 41 | /// |
| 42 | /// \param r The input range |
| 43 | /// \param p A predicate for testing the elements of the range |
| 44 | /// |
| 45 | template<typename Range, typename Predicate> |
| 46 | BOOST_CXX14_CONSTEXPR typename boost::range_iterator<const Range>::type find_if_not ( const Range &r, Predicate p ) |
| 47 | { |
| 48 | return boost::algorithm::find_if_not (boost::begin (r), boost::end(r), p); |
| 49 | } |
| 50 | |
| 51 | }} |
| 52 | #endif // BOOST_ALGORITHM_FIND_IF_NOT_HPP |
| 53 | |