iter.pass.cpp (1010B)
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 // explicit constexpr reverse_iterator(Iter x); 15 // 16 // constexpr in C++17 17 18 #include <iterator> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "test_iterators.h" 23 24 template <class It> 25 void 26 test(It i) 27 { 28 std::reverse_iterator<It> r(i); 29 assert(r.base() == i); 30 } 31 32 int main() 33 { 34 const char s[] = "123"; 35 test(bidirectional_iterator<const char*>(s)); 36 test(random_access_iterator<const char*>(s)); 37 test(s); 38 39 #if TEST_STD_VER > 14 40 { 41 constexpr const char *p = "123456789"; 42 constexpr std::reverse_iterator<const char *> it(p); 43 static_assert(it.base() == p); 44 } 45 #endif 46 }