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 // void swap(basic_string_view& _other) noexcept
15 #include <string_view>
18 #include "test_macros.h"
20 template <typename CharT
>
21 void test(const CharT
* s
, std::size_t len
) {
22 typedef std::basic_string_view
<CharT
> SV
;
27 assert(sv1
.size() == len
);
28 assert(sv1
.data() == s
);
29 assert(sv2
.size() == 0);
32 assert(sv1
.size() == 0);
33 assert(sv2
.size() == len
);
34 assert(sv2
.data() == s
);
39 constexpr std::size_t test_ce(size_t n
, size_t k
) {
40 typedef std::basic_string_view
<char> SV
;
41 SV sv1
{"ABCDEFGHIJKL", n
};
42 SV sv2
{sv1
.data(), k
};
48 int main(int, char**) {
53 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
59 #if TEST_STD_VER >= 11
71 static_assert(test_ce(2, 3) == 3, "");
72 static_assert(test_ce(5, 3) == 3, "");
73 static_assert(test_ce(0, 1) == 1, "");