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 Eric Niebler 2014-present
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 //===-------------------------- algorithm ---------------------------------===//
0014 //
0015 //                     The LLVM Compiler Infrastructure
0016 //
0017 // This file is dual licensed under the MIT and the University of Illinois Open
0018 // Source Licenses. See LICENSE.TXT for details.
0019 //
0020 //===----------------------------------------------------------------------===//
0021 #ifndef RANGES_V3_ALGORITHM_IS_PARTITIONED_HPP
0022 #define RANGES_V3_ALGORITHM_IS_PARTITIONED_HPP
0023 
0024 #include <meta/meta.hpp>
0025 
0026 #include <range/v3/range_fwd.hpp>
0027 
0028 #include <range/v3/functional/identity.hpp>
0029 #include <range/v3/functional/invoke.hpp>
0030 #include <range/v3/iterator/concepts.hpp>
0031 #include <range/v3/iterator/traits.hpp>
0032 #include <range/v3/range/access.hpp>
0033 #include <range/v3/range/concepts.hpp>
0034 #include <range/v3/range/traits.hpp>
0035 #include <range/v3/utility/static_const.hpp>
0036 
0037 #include <range/v3/detail/prologue.hpp>
0038 
0039 namespace ranges
0040 {
0041     /// \addtogroup group-algorithms
0042     /// @{
0043     RANGES_FUNC_BEGIN(is_partitioned)
0044 
0045         /// \brief function template \c is_partitioned
0046         template(typename I, typename S, typename C, typename P = identity)(
0047             requires input_iterator<I> AND sentinel_for<S, I> AND
0048             indirect_unary_predicate<C, projected<I, P>>)
0049         constexpr bool RANGES_FUNC(is_partitioned)(I first, S last, C pred, P proj = P{}) //
0050         {
0051             for(; first != last; ++first)
0052                 if(!invoke(pred, invoke(proj, *first)))
0053                     break;
0054             for(; first != last; ++first)
0055                 if(invoke(pred, invoke(proj, *first)))
0056                     return false;
0057             return true;
0058         }
0059 
0060         /// \overload
0061         template(typename Rng, typename C, typename P = identity)(
0062             requires input_range<Rng> AND
0063             indirect_unary_predicate<C, projected<iterator_t<Rng>, P>>)
0064         constexpr bool RANGES_FUNC(is_partitioned)(Rng && rng, C pred, P proj = P{}) //
0065         {
0066             return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
0067         }
0068 
0069     RANGES_FUNC_END(is_partitioned)
0070 
0071     namespace cpp20
0072     {
0073         using ranges::is_partitioned;
0074     }
0075     /// @}
0076 } // namespace ranges
0077 
0078 #include <range/v3/detail/epilogue.hpp>
0079 
0080 #endif