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 // <string> 10 11 // reverse_iterator rend(); 12 // const_reverse_iterator rend() const; 13 14 #include <string> 15 #include <cassert> 16 #include <cstddef> 17 18 #include "min_allocator.h" 19 20 template <class S> 21 void 22 test(S s) 23 { 24 const S& cs = s; 25 typename S::reverse_iterator e = s.rend(); 26 typename S::const_reverse_iterator ce = cs.rend(); 27 if (s.empty()) 28 { 29 assert(e == s.rbegin()); 30 assert(ce == cs.rbegin()); 31 } 32 assert(static_cast<std::size_t>(e - s.rbegin()) == s.size()); 33 assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size()); 34 } 35 36 int main(int, char**) 37 { 38 { 39 typedef std::string S; 40 test(S()); 41 test(S("123")); 42 } 43 #if TEST_STD_VER >= 11 44 { 45 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 46 test(S()); 47 test(S("123")); 48 } 49 #endif 50 51 return 0; 52 } 53