Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Andrew Sutton 2014
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_ALL_OF_HPP
0014 #define RANGES_V3_ALGORITHM_ALL_OF_HPP
0015 
0016 #include <utility>
0017 
0018 #include <range/v3/range_fwd.hpp>
0019 
0020 #include <range/v3/functional/identity.hpp>
0021 #include <range/v3/functional/invoke.hpp>
0022 #include <range/v3/iterator/concepts.hpp>
0023 #include <range/v3/iterator/traits.hpp>
0024 #include <range/v3/range/access.hpp>
0025 #include <range/v3/range/concepts.hpp>
0026 #include <range/v3/range/traits.hpp>
0027 #include <range/v3/utility/static_const.hpp>
0028 
0029 #include <range/v3/detail/prologue.hpp>
0030 
0031 namespace ranges
0032 {
0033     /// \addtogroup group-algorithms
0034     /// @{
0035     RANGES_FUNC_BEGIN(all_of)
0036 
0037         /// \brief function template \c all_of
0038         template(typename I, typename S, typename F, typename P = identity)(
0039             requires input_iterator<I> AND sentinel_for<S, I> AND
0040             indirect_unary_predicate<F, projected<I, P>>)
0041         constexpr bool RANGES_FUNC(all_of)(I first, S last, F pred, P proj = P{}) //
0042         {
0043             for(; first != last; ++first)
0044                 if(!invoke(pred, invoke(proj, *first)))
0045                     break;
0046             return first == last;
0047         }
0048 
0049         /// \overload
0050         template(typename Rng, typename F, typename P = identity)(
0051             requires input_range<Rng> AND
0052             indirect_unary_predicate<F, projected<iterator_t<Rng>, P>>)
0053         constexpr bool RANGES_FUNC(all_of)(Rng && rng, F pred, P proj = P{}) //
0054         {
0055             return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
0056         }
0057 
0058     RANGES_FUNC_END(all_of)
0059 
0060     namespace cpp20
0061     {
0062         using ranges::all_of;
0063     }
0064     /// @}
0065 } // namespace ranges
0066 
0067 #include <range/v3/detail/epilogue.hpp>
0068 
0069 #endif