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 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <string> |
| 11 | |
| 12 | // reverse_iterator rend(); |
| 13 | // const_reverse_iterator rend() const; |
| 14 | |
| 15 | #include <string> |
| 16 | #include <cassert> |
| 17 | |
| 18 | template <class S> |
| 19 | void |
| 20 | test(S s) |
| 21 | { |
| 22 | const S& cs = s; |
| 23 | typename S::reverse_iterator e = s.rend(); |
| 24 | typename S::const_reverse_iterator ce = cs.rend(); |
| 25 | if (s.empty()) |
| 26 | { |
| 27 | assert(e == s.rbegin()); |
| 28 | assert(ce == cs.rbegin()); |
| 29 | } |
| 30 | assert(e - s.rbegin() == s.size()); |
| 31 | assert(ce - cs.rbegin() == cs.size()); |
| 32 | } |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | typedef std::string S; |
| 37 | test(S()); |
| 38 | test(S("123")); |
| 39 | } |