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 // template <class _Iterator> 10 // struct __bounded_iter; 11 // 12 // Comparison operators 13 14 #include <iterator> 15 16 #include "test_iterators.h" 17 #include "test_macros.h" 18 19 template <class Iter> 20 TEST_CONSTEXPR_CXX14 bool tests() { 21 int array[] = {0, 1, 2, 3, 4}; 22 int* b = array + 0; 23 int* e = array + 5; 24 std::__bounded_iter<Iter> const iter1 = std::__make_bounded_iter(Iter(b), Iter(b), Iter(e)); 25 std::__bounded_iter<Iter> const iter2 = std::__make_bounded_iter(Iter(e), Iter(b), Iter(e)); 26 27 // operator== 28 { 29 assert(iter1 == iter1); 30 assert(!(iter1 == iter2)); 31 } 32 // operator!= 33 { 34 assert(iter1 != iter2); 35 assert(!(iter1 != iter1)); 36 } 37 // operator< 38 { 39 assert(iter1 < iter2); 40 assert(!(iter2 < iter1)); 41 assert(!(iter1 < iter1)); 42 } 43 // operator> 44 { 45 assert(iter2 > iter1); 46 assert(!(iter1 > iter2)); 47 assert(!(iter1 > iter1)); 48 } 49 // operator<= 50 { 51 assert(iter1 <= iter2); 52 assert(!(iter2 <= iter1)); 53 assert(iter1 <= iter1); 54 } 55 // operator>= 56 { 57 assert(iter2 >= iter1); 58 assert(!(iter1 >= iter2)); 59 assert(iter1 >= iter1); 60 } 61 62 return true; 63 } 64 65 int main(int, char**) { 66 tests<int*>(); 67 #if TEST_STD_VER > 11 68 static_assert(tests<int*>(), ""); 69 #endif 70 71 #if TEST_STD_VER > 17 72 tests<contiguous_iterator<int*> >(); 73 static_assert(tests<contiguous_iterator<int*> >(), ""); 74 #endif 75 76 return 0; 77 } 78