blob: 1f70b4458c7e0c91b53fbc692a26eb4190be7e56 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-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 Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// const charT& back() const;
13// charT& back();
14
15#include <string>
16#include <cassert>
17
18template <class S>
19void
20test(S s)
21{
22 const S& cs = s;
23 assert(&cs.back() == &cs[cs.size()-1]);
24 assert(&s.back() == &s[cs.size()-1]);
25 s.back() = typename S::value_type('z');
26 assert(s.back() == typename S::value_type('z'));
27}
28
29int main()
30{
31 typedef std::string S;
32 test(S("1"));
33 test(S("1234567890123456789012345678901234567890"));
34}