1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // constexpr const_iterator end() const;
14 #include <experimental/string_view>
22 typename S::iterator e = s.end();
23 typename S::const_iterator ce1 = cs.end();
24 typename S::const_iterator ce2 = s.cend();
28 assert( e == s.begin());
29 assert(ce1 == cs.begin());
30 assert(ce2 == s.begin());
34 assert( e != s.begin());
35 assert(ce1 != cs.begin());
36 assert(ce2 != s.begin());
39 assert( e - s.begin() == s.size());
40 assert(ce1 - cs.begin() == cs.size());
41 assert(ce2 - s.cbegin() == s.size());
51 typedef std::experimental::string_view string_view;
52 typedef std::experimental::u16string_view u16string_view;
53 typedef std::experimental::u32string_view u32string_view;
54 typedef std::experimental::wstring_view wstring_view;
57 test(u16string_view());
58 test(u32string_view());
59 test(wstring_view ());
60 test(string_view ( "123"));
61 test(wstring_view (L"123"));
62 #if __cplusplus >= 201103L
63 test(u16string_view{u"123"});
64 test(u32string_view{U"123"});
67 #if _LIBCPP_STD_VER > 11
69 constexpr string_view sv { "123", 3 };
70 constexpr u16string_view u16sv {u"123", 3 };
71 constexpr u32string_view u32sv {U"123", 3 };
72 constexpr wstring_view wsv {L"123", 3 };
74 static_assert ( sv.begin() != sv.end(), "" );
75 static_assert ( u16sv.begin() != u16sv.end(), "" );
76 static_assert ( u32sv.begin() != u32sv.end(), "" );
77 static_assert ( wsv.begin() != wsv.end(), "" );
79 static_assert ( sv.begin() != sv.cend(), "" );
80 static_assert ( u16sv.begin() != u16sv.cend(), "" );
81 static_assert ( u32sv.begin() != u32sv.cend(), "" );
82 static_assert ( wsv.begin() != wsv.cend(), "" );