1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // const charT& front() const; 13 // charT& front(); 14 15 #ifdef _LIBCPP_DEBUG 16 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 17 #endif 18 19 #include <string> 20 #include <cassert> 21 22 #include "min_allocator.h" 23 24 template <class S> 25 void test(S s)26test(S s) 27 { 28 const S& cs = s; 29 assert(&cs.front() == &cs[0]); 30 assert(&s.front() == &s[0]); 31 s.front() = typename S::value_type('z'); 32 assert(s.front() == typename S::value_type('z')); 33 } 34 main()35int main() 36 { 37 { 38 typedef std::string S; 39 test(S("1")); 40 test(S("1234567890123456789012345678901234567890")); 41 } 42 #if TEST_STD_VER >= 11 43 { 44 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 45 test(S("1")); 46 test(S("1234567890123456789012345678901234567890")); 47 } 48 #endif 49 #ifdef _LIBCPP_DEBUG 50 { 51 std::string s; 52 char c = s.front(); 53 assert(false); 54 } 55 #endif 56 } 57