Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <string> |
| 11 | |
| 12 | // reverse_iterator rend(); |
| 13 | // const_reverse_iterator rend() const; |
| 14 | |
| 15 | #include <string> |
| 16 | #include <cassert> |
| 17 | |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 18 | #include "../min_allocator.h" |
| 19 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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(e - s.rbegin() == s.size()); |
| 33 | assert(ce - cs.rbegin() == cs.size()); |
| 34 | } |
| 35 | |
| 36 | int main() |
| 37 | { |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 38 | { |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 39 | typedef std::string S; |
| 40 | test(S()); |
| 41 | test(S("123")); |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 42 | } |
| 43 | #if __cplusplus >= 201103L |
| 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 |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 50 | } |