blob: ecfafb54bd0331380cc3c73aae29eb96e47a2a4d [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// const charT& front() const;
13// charT& front();
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 assert(&cs.front() == &cs[0]);
26 assert(&s.front() == &s[0]);
27 s.front() = typename S::value_type('z');
28 assert(s.front() == typename S::value_type('z'));
29}
30
31int main()
32{
Howard Hinnanteec72182013-06-28 16:59:19 +000033 {
Howard Hinnant3e519522010-05-11 19:42:16 +000034 typedef std::string S;
35 test(S("1"));
36 test(S("1234567890123456789012345678901234567890"));
Howard Hinnanteec72182013-06-28 16:59:19 +000037 }
38#if __cplusplus >= 201103L
39 {
40 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
41 test(S("1"));
42 test(S("1234567890123456789012345678901234567890"));
43 }
44#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000045}