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 // iterator end(); 13 // const_iterator end() const; 14 15 #include <string> 16 #include <cassert> 17 18 #include "min_allocator.h" 19 20 template <class S> 21 void test(S s)22test(S s) 23 { 24 const S& cs = s; 25 typename S::iterator e = s.end(); 26 typename S::const_iterator ce = cs.end(); 27 if (s.empty()) 28 { 29 assert(e == s.begin()); 30 assert(ce == cs.begin()); 31 } 32 assert(e - s.begin() == s.size()); 33 assert(ce - cs.begin() == cs.size()); 34 } 35 main()36int main() 37 { 38 { 39 typedef std::string S; 40 test(S()); 41 test(S("123")); 42 } 43 #if __cplusplus >= 201103L 44 { 45 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 46 test(S()); 47 test(S("123")); 48 } 49 #endif 50 } 51