Back to home page

EIC code displayed by LXR

 
 

    


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

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 #ifndef RANGES_V3_ALGORITHM_REMOVE_COPY_IF_HPP
0014 #define RANGES_V3_ALGORITHM_REMOVE_COPY_IF_HPP
0015 
0016 #include <meta/meta.hpp>
0017 
0018 #include <range/v3/range_fwd.hpp>
0019 
0020 #include <range/v3/algorithm/result_types.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/iterator/concepts.hpp>
0024 #include <range/v3/iterator/traits.hpp>
0025 #include <range/v3/range/access.hpp>
0026 #include <range/v3/range/concepts.hpp>
0027 #include <range/v3/range/dangling.hpp>
0028 #include <range/v3/range/traits.hpp>
0029 #include <range/v3/utility/static_const.hpp>
0030 
0031 #include <range/v3/detail/prologue.hpp>
0032 
0033 namespace ranges
0034 {
0035     /// \addtogroup group-algorithms
0036     /// @{
0037     template<typename I, typename O>
0038     using remove_copy_if_result = detail::in_out_result<I, O>;
0039 
0040     RANGES_FUNC_BEGIN(remove_copy_if)
0041 
0042         /// \brief function template \c remove_copy_if
0043         template(typename I, typename S, typename O, typename C, typename P = identity)(
0044             requires input_iterator<I> AND sentinel_for<S, I> AND
0045             weakly_incrementable<O> AND indirect_unary_predicate<C, projected<I, P>> AND
0046             indirectly_copyable<I, O>)
0047         constexpr remove_copy_if_result<I, O> //
0048         RANGES_FUNC(remove_copy_if)(I first, S last, O out, C pred, P proj = P{}) //
0049         {
0050             for(; first != last; ++first)
0051             {
0052                 auto && x = *first;
0053                 if(!(invoke(pred, invoke(proj, x))))
0054                 {
0055                     *out = (decltype(x) &&)x;
0056                     ++out;
0057                 }
0058             }
0059             return {first, out};
0060         }
0061 
0062         /// \overload
0063         template(typename Rng, typename O, typename C, typename P = identity)(
0064             requires input_range<Rng> AND weakly_incrementable<O> AND
0065             indirect_unary_predicate<C, projected<iterator_t<Rng>, P>> AND
0066             indirectly_copyable<iterator_t<Rng>, O>)
0067         constexpr remove_copy_if_result<borrowed_iterator_t<Rng>, O> //
0068         RANGES_FUNC(remove_copy_if)(Rng && rng, O out, C pred, P proj = P{}) //
0069         {
0070             return (*this)(
0071                 begin(rng), end(rng), std::move(out), std::move(pred), std::move(proj));
0072         }
0073 
0074     RANGES_FUNC_END(remove_copy_if)
0075 
0076     namespace cpp20
0077     {
0078         using ranges::remove_copy_if;
0079         using ranges::remove_copy_if_result;
0080     } // namespace cpp20
0081     /// @}
0082 } // namespace ranges
0083 
0084 #include <range/v3/detail/epilogue.hpp>
0085 
0086 #endif