Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / cxx11 / find_if_not.hpp @ 2486

History | View | Annotate | Download (2 kB)

1 2486 sjacqu01
/*
2 2486 sjacqu01
   Copyright (c) Marshall Clow 2011-2012.
3 2486 sjacqu01

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