[AMDGPU] Mark AGPR tuple implicit in the first instr of AGPR spills. (#115285)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / counted.iterator / decrement.pass.cpp
blob7b3c526b1280f732a9302e08f71473878a21ea44
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // constexpr counted_iterator& operator--()
12 // requires bidirectional_iterator<I>;
13 // constexpr counted_iterator operator--(int)
14 // requires bidirectional_iterator<I>;
16 #include <iterator>
18 #include "test_macros.h"
19 #include "test_iterators.h"
21 template<class Iter>
22 concept MinusEnabled = requires(Iter& iter) {
23 iter--;
24 --iter;
27 constexpr bool test() {
28 int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8};
31 using Counted = std::counted_iterator<bidirectional_iterator<int*>>;
32 std::counted_iterator iter(bidirectional_iterator<int*>{buffer + 2}, 6);
33 assert(iter-- == Counted(bidirectional_iterator<int*>{buffer + 2}, 6));
34 assert(--iter == Counted(bidirectional_iterator<int*>{buffer}, 8));
35 assert(iter.count() == 8);
37 ASSERT_SAME_TYPE(decltype(iter--), Counted);
38 ASSERT_SAME_TYPE(decltype(--iter), Counted&);
41 using Counted = std::counted_iterator<random_access_iterator<int*>>;
42 Counted iter(random_access_iterator<int*>{buffer + 2}, 6);
43 assert(iter-- == Counted(random_access_iterator<int*>{buffer + 2}, 6));
44 assert(--iter == Counted(random_access_iterator<int*>{buffer}, 8));
45 assert(iter.count() == 8);
47 ASSERT_SAME_TYPE(decltype(iter--), Counted);
48 ASSERT_SAME_TYPE(decltype(--iter), Counted&);
51 using Counted = std::counted_iterator<contiguous_iterator<int*>>;
52 std::counted_iterator iter(contiguous_iterator<int*>{buffer + 2}, 6);
53 assert(iter-- == Counted(contiguous_iterator<int*>{buffer + 2}, 6));
54 assert(--iter == Counted(contiguous_iterator<int*>{buffer}, 8));
55 assert(iter.count() == 8);
57 ASSERT_SAME_TYPE(decltype(iter--), Counted);
58 ASSERT_SAME_TYPE(decltype(--iter), Counted&);
62 static_assert( MinusEnabled<std::counted_iterator<contiguous_iterator<int*>>>);
63 static_assert(!MinusEnabled<const std::counted_iterator<contiguous_iterator<int*>>>);
64 static_assert(!MinusEnabled<std::counted_iterator<forward_iterator<int*>>>);
67 return true;
70 int main(int, char**) {
71 test();
72 static_assert(test());
74 return 0;