1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_CHUNK_BY_TYPES_H 10 #define TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_CHUNK_BY_TYPES_H 11 12 #include <ranges> 13 #include <utility> 14 15 #include "test_iterators.h" 16 17 struct TrackInitialization { TrackInitializationTrackInitialization18 constexpr explicit TrackInitialization(bool* moved, bool* copied) : moved_(moved), copied_(copied) {} TrackInitializationTrackInitialization19 constexpr TrackInitialization(TrackInitialization const& other) : moved_(other.moved_), copied_(other.copied_) { 20 *copied_ = true; 21 } TrackInitializationTrackInitialization22 constexpr TrackInitialization(TrackInitialization&& other) : moved_(other.moved_), copied_(other.copied_) { 23 *moved_ = true; 24 } 25 TrackInitialization& operator=(TrackInitialization const&) = default; 26 TrackInitialization& operator=(TrackInitialization&&) = default; 27 bool* moved_; 28 bool* copied_; 29 }; 30 31 enum class IsConst : bool { no, yes }; 32 33 template <std::forward_iterator Iter, std::sentinel_for<Iter> Sent = sentinel_wrapper<Iter>> 34 struct View : std::ranges::view_base { ViewView35 constexpr explicit View(Iter b, Sent e) : begin_(b), end_(e) {} beginView36 constexpr Iter begin() { return begin_; } endView37 constexpr Sent end() { return end_; } 38 39 private: 40 Iter begin_; 41 Sent end_; 42 }; 43 44 template <class I, class S> 45 View(I b, S e) -> View<I, S>; 46 47 struct IntWrapper { IntWrapperIntWrapper48 constexpr IntWrapper(int v) : value_(v) {} 49 50 int value_; lessEqualIntWrapper51 constexpr bool lessEqual(IntWrapper other) const { return value_ <= other.value_; } 52 }; 53 54 #endif // TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_CHUNK_BY_TYPES_H 55