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
17 #include <string_view>
19 #include "test_macros.h"
21 template <typename CharT
>
22 void test(const CharT
* s
, std::size_t len
) {
23 typedef std::basic_string_view
<CharT
> SV
;
28 assert(sv1
.size() == len
);
29 assert(sv1
.data() == s
);
30 assert(sv2
.size() == 0);
33 assert(sv1
.size() == 0);
34 assert(sv2
.size() == len
);
35 assert(sv2
.data() == s
);
40 constexpr std::size_t test_ce(size_t n
, size_t k
) {
41 typedef std::basic_string_view
<char> SV
;
42 SV sv1
{"ABCDEFGHIJKL", n
};
43 SV sv2
{sv1
.data(), k
};
49 int main(int, char**) {
54 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
60 #if TEST_STD_VER >= 11
72 static_assert(test_ce(2, 3) == 3, "");
73 static_assert(test_ce(5, 3) == 3, "");
74 static_assert(test_ce(0, 1) == 1, "");