blob: edb02d719abca31be185853cf0a1753acf494dc0 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// reverse_iterator rbegin();
13// const_reverse_iterator rbegin() const;
14
15#include <string>
16#include <cassert>
17
Howard Hinnanteec72182013-06-28 16:59:19 +000018#include "../min_allocator.h"
19
Howard Hinnant3e519522010-05-11 19:42:16 +000020template <class S>
21void
22test(S s)
23{
24 const S& cs = s;
25 typename S::reverse_iterator b = s.rbegin();
26 typename S::const_reverse_iterator cb = cs.rbegin();
27 if (!s.empty())
28 {
29 assert(*b == s.back());
30 }
31 assert(b == cb);
32}
33
34int main()
35{
Howard Hinnanteec72182013-06-28 16:59:19 +000036 {
Howard Hinnant3e519522010-05-11 19:42:16 +000037 typedef std::string S;
38 test(S());
39 test(S("123"));
Howard Hinnanteec72182013-06-28 16:59:19 +000040 }
41#if __cplusplus >= 201103L
42 {
43 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
44 test(S());
45 test(S("123"));
46 }
47#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000048}