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 //===----------------------------------------------------------------------===//
13 // constexpr const _CharT& operator[](size_type _pos) const;
15 #include <experimental/string_view>
18 #include "test_macros.h"
20 template <typename CharT>
21 void test ( const CharT *s, size_t len ) {
22 std::experimental::basic_string_view<CharT> sv ( s, len );
23 assert ( sv.length() == len );
24 for ( size_t i = 0; i < len; ++i ) {
25 assert ( sv[i] == s[i] );
26 assert ( &sv[i] == s + i );
37 #if TEST_STD_VER >= 11
47 constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
48 static_assert ( sv.length() == 2, "" );
49 static_assert ( sv[0] == 'A', "" );
50 static_assert ( sv[1] == 'B', "" );