Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame^] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure |
| 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 | // const charT& back() const; |
| 13 | // charT& back(); |
| 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 | 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 | |
| 29 | int main() |
| 30 | { |
| 31 | typedef std::string S; |
| 32 | test(S("1")); |
| 33 | test(S("1234567890123456789012345678901234567890")); |
| 34 | } |