Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:53

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Johel Guerrero 2019
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 #ifndef RANGES_V3_ALGORITHM_CONTAINS_HPP
0014 #define RANGES_V3_ALGORITHM_CONTAINS_HPP
0015 
0016 #include <utility>
0017 
0018 #include <concepts/concepts.hpp>
0019 
0020 #include <range/v3/algorithm/find.hpp>
0021 #include <range/v3/detail/config.hpp>
0022 #include <range/v3/functional/comparisons.hpp>
0023 #include <range/v3/functional/identity.hpp>
0024 #include <range/v3/iterator/concepts.hpp>
0025 #include <range/v3/range/access.hpp>
0026 #include <range/v3/range/concepts.hpp>
0027 
0028 #include <range/v3/detail/prologue.hpp>
0029 
0030 namespace ranges
0031 {
0032     /// \addtogroup group-algorithms
0033     /// @{
0034     RANGES_FUNC_BEGIN(contains)
0035 
0036         /// \brief function template \c contains
0037         template(typename I, typename S, typename T, typename P = identity)(
0038             requires input_iterator<I> AND sentinel_for<S, I> AND
0039             indirect_relation<equal_to, projected<I, P>, const T *>)
0040         constexpr bool RANGES_FUNC(contains)(I first, S last, const T & val, P proj = {})
0041         {
0042             return find(std::move(first), last, val, std::move(proj)) != last;
0043         }
0044 
0045         /// \overload
0046         template(typename Rng, typename T, typename P = identity)(
0047             requires input_range<Rng> AND
0048             indirect_relation<equal_to, projected<iterator_t<Rng>, P>, const T *>)
0049         constexpr bool RANGES_FUNC(contains)(Rng && rng, const T & val, P proj = {})
0050         {
0051             return (*this)(begin(rng), end(rng), val, std::move(proj));
0052         }
0053 
0054     RANGES_FUNC_END(contains)
0055     /// @}
0056 } // namespace ranges
0057 
0058 #include <range/v3/detail/epilogue.hpp>
0059 
0060 #endif // RANGES_V3_ALGORITHM_CONTAINS_HPP