1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)
13 // constexpr basic_string_view(const _CharT* _s)
14 // : __data (_s), __size(_Traits::length(_s)) {}
16 #include <string_view>
20 #include "test_macros.h"
21 #include "constexpr_char_traits.h"
23 template <typename CharT
>
24 size_t StrLen(const CharT
* s
) {
25 std::size_t retVal
= 0;
33 template <typename CharT
>
34 void test(const CharT
* s
) {
35 typedef std::basic_string_view
<CharT
> SV
;
36 // I'd love to do this, but it would require traits::length() to be noexcept
37 // LIBCPP_ASSERT_NOEXCEPT(SV(s));
40 assert(sv1
.size() == StrLen(s
));
41 assert(sv1
.data() == s
);
44 int main(int, char**) {
49 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
55 #if TEST_STD_VER >= 11
67 constexpr std::basic_string_view
<char, constexpr_char_traits
<char>> sv1("ABCDE");
68 static_assert(sv1
.size() == 5, "");