Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:59

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-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 
0014 #ifndef RANGES_V3_VIEW_UNIQUE_HPP
0015 #define RANGES_V3_VIEW_UNIQUE_HPP
0016 
0017 #include <utility>
0018 
0019 #include <meta/meta.hpp>
0020 
0021 #include <range/v3/range_fwd.hpp>
0022 
0023 #include <range/v3/functional/bind_back.hpp>
0024 #include <range/v3/functional/not_fn.hpp>
0025 #include <range/v3/utility/static_const.hpp>
0026 #include <range/v3/view/adjacent_filter.hpp>
0027 #include <range/v3/view/all.hpp>
0028 #include <range/v3/view/view.hpp>
0029 
0030 #include <range/v3/detail/prologue.hpp>
0031 
0032 namespace ranges
0033 {
0034     /// \addtogroup group-views
0035     /// @{
0036     namespace views
0037     {
0038         struct unique_base_fn
0039         {
0040             template(typename Rng, typename C = equal_to)(
0041                 requires viewable_range<Rng> AND forward_range<Rng> AND
0042                     indirect_relation<C, iterator_t<Rng>>)
0043             constexpr adjacent_filter_view<all_t<Rng>, logical_negate<C>> //
0044             operator()(Rng && rng, C pred = {}) const
0045             {
0046                 return {all(static_cast<Rng &&>(rng)), not_fn(pred)};
0047             }
0048         };
0049 
0050         struct unique_fn : unique_base_fn
0051         {
0052             using unique_base_fn::operator();
0053 
0054             template(typename C)(
0055                 requires (!range<C>))
0056             constexpr auto operator()(C && pred) const
0057             {
0058                 return make_view_closure(
0059                     bind_back(unique_base_fn{}, static_cast<C &&>(pred)));
0060             }
0061         };
0062 
0063         /// \relates unique_fn
0064         /// \ingroup group-views
0065         RANGES_INLINE_VARIABLE(view_closure<unique_fn>, unique)
0066     } // namespace views
0067     /// @}
0068 } // namespace ranges
0069 
0070 #include <range/v3/detail/epilogue.hpp>
0071 
0072 #endif