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