14684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 24684ddb6SLionel Sambuc // 34684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure 44684ddb6SLionel Sambuc // 54684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 64684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 74684ddb6SLionel Sambuc // 84684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 94684ddb6SLionel Sambuc 104684ddb6SLionel Sambuc // <string> 114684ddb6SLionel Sambuc 124684ddb6SLionel Sambuc // const_reference operator[](size_type pos) const; 134684ddb6SLionel Sambuc // reference operator[](size_type pos); 144684ddb6SLionel Sambuc 154684ddb6SLionel Sambuc #ifdef _LIBCPP_DEBUG 164684ddb6SLionel Sambuc #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 174684ddb6SLionel Sambuc #endif 184684ddb6SLionel Sambuc 194684ddb6SLionel Sambuc #include <string> 204684ddb6SLionel Sambuc #include <cassert> 214684ddb6SLionel Sambuc 22*0a6a1f1dSLionel Sambuc #include "min_allocator.h" 234684ddb6SLionel Sambuc main()244684ddb6SLionel Sambucint main() 254684ddb6SLionel Sambuc { 264684ddb6SLionel Sambuc { 274684ddb6SLionel Sambuc typedef std::string S; 284684ddb6SLionel Sambuc S s("0123456789"); 294684ddb6SLionel Sambuc const S& cs = s; 304684ddb6SLionel Sambuc for (S::size_type i = 0; i < cs.size(); ++i) 314684ddb6SLionel Sambuc { 324684ddb6SLionel Sambuc assert(s[i] == '0' + i); 334684ddb6SLionel Sambuc assert(cs[i] == s[i]); 344684ddb6SLionel Sambuc } 354684ddb6SLionel Sambuc assert(cs[cs.size()] == '\0'); 364684ddb6SLionel Sambuc const S s2 = S(); 374684ddb6SLionel Sambuc assert(s2[0] == '\0'); 384684ddb6SLionel Sambuc } 394684ddb6SLionel Sambuc #if __cplusplus >= 201103L 404684ddb6SLionel Sambuc { 414684ddb6SLionel Sambuc typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 424684ddb6SLionel Sambuc S s("0123456789"); 434684ddb6SLionel Sambuc const S& cs = s; 444684ddb6SLionel Sambuc for (S::size_type i = 0; i < cs.size(); ++i) 454684ddb6SLionel Sambuc { 464684ddb6SLionel Sambuc assert(s[i] == '0' + i); 474684ddb6SLionel Sambuc assert(cs[i] == s[i]); 484684ddb6SLionel Sambuc } 494684ddb6SLionel Sambuc assert(cs[cs.size()] == '\0'); 504684ddb6SLionel Sambuc const S s2 = S(); 514684ddb6SLionel Sambuc assert(s2[0] == '\0'); 524684ddb6SLionel Sambuc } 534684ddb6SLionel Sambuc #endif 544684ddb6SLionel Sambuc #ifdef _LIBCPP_DEBUG 554684ddb6SLionel Sambuc { 564684ddb6SLionel Sambuc std::string s; 574684ddb6SLionel Sambuc char c = s[0]; 584684ddb6SLionel Sambuc assert(c == '\0'); 594684ddb6SLionel Sambuc c = s[1]; 604684ddb6SLionel Sambuc assert(false); 614684ddb6SLionel Sambuc } 624684ddb6SLionel Sambuc #endif 634684ddb6SLionel Sambuc } 64