1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <iterator> 11 12// reverse_iterator 13 14// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 15// requires HasGreater<Iter1, Iter2> 16// constexpr bool 17// operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y); 18// 19// constexpr in c++17 20 21#include <iterator> 22#include <cassert> 23 24#include "test_macros.h" 25#include "test_iterators.h" 26 27template <class It> 28void 29test(It l, It r, bool x) 30{ 31 const std::reverse_iterator<It> r1(l); 32 const std::reverse_iterator<It> r2(r); 33 assert((r1 <= r2) == x); 34} 35 36int main() 37{ 38 const char* s = "1234567890"; 39 test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true); 40 test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false); 41 test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true); 42 test(s, s, true); 43 test(s, s+1, false); 44 test(s+1, s, true); 45 46#if TEST_STD_VER > 14 47 { 48 constexpr const char *p = "123456789"; 49 typedef std::reverse_iterator<const char *> RI; 50 constexpr RI it1 = std::make_reverse_iterator(p); 51 constexpr RI it2 = std::make_reverse_iterator(p); 52 constexpr RI it3 = std::make_reverse_iterator(p+1); 53 static_assert( (it1 <= it2), ""); 54 static_assert(!(it1 <= it3), ""); 55 } 56#endif 57} 58