blob: 0018cc567522eaa9a0553260dfcee99a14fcb691 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
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_reference operator[](size_type pos) const;
13// reference operator[](size_type pos);
14
15#include <string>
16#include <cassert>
17
18int main()
19{
20 typedef std::string S;
21 S s("0123456789");
22 const S& cs = s;
23 for (S::size_type i = 0; i < cs.size(); ++i)
24 {
25 assert(s[i] == '0' + i);
26 assert(cs[i] == s[i]);
27 }
28 assert(cs[cs.size()] == '\0');
29 const S s2 = S();
30 assert(s2[0] == '\0');
31}