Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 5 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2013-present
  5. //
  6. // Use, modification and distribution is subject to the
  7. // Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // Project home: https://github.com/ericniebler/range-v3
  12. //
  13. #ifndef RANGES_V3_VIEW_UNIQUE_HPP
  14. #define RANGES_V3_VIEW_UNIQUE_HPP
  15. #include <utility>
  16. #include <meta/meta.hpp>
  17. #include <range/v3/range_fwd.hpp>
  18. #include <range/v3/functional/bind_back.hpp>
  19. #include <range/v3/functional/not_fn.hpp>
  20. #include <range/v3/utility/static_const.hpp>
  21. #include <range/v3/view/adjacent_filter.hpp>
  22. #include <range/v3/view/all.hpp>
  23. #include <range/v3/view/view.hpp>
  24. namespace ranges
  25. {
  26. /// \addtogroup group-views
  27. /// @{
  28. namespace views
  29. {
  30. struct unique_fn
  31. {
  32. private:
  33. friend view_access;
  34. template<typename C>
  35. static constexpr auto CPP_fun(bind)(unique_fn unique, C pred)( //
  36. requires(!range<C>))
  37. {
  38. return bind_back(unique, std::move(pred));
  39. }
  40. public:
  41. template<typename Rng, typename C = equal_to>
  42. constexpr auto operator()(Rng && rng, C pred = {}) const
  43. -> CPP_ret(adjacent_filter_view<all_t<Rng>, logical_negate<C>>)( //
  44. requires viewable_range<Rng> && forward_range<Rng> &&
  45. indirect_relation<C, iterator_t<Rng>>)
  46. {
  47. return {all(static_cast<Rng &&>(rng)), not_fn(pred)};
  48. }
  49. };
  50. /// \relates unique_fn
  51. /// \ingroup group-views
  52. RANGES_INLINE_VARIABLE(view<unique_fn>, unique)
  53. } // namespace views
  54. /// @}
  55. } // namespace ranges
  56. #endif