xref: /aosp_15_r20/external/libcxx/test/std/strings/string.view/string.view.cons/default.pass.cpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 
11 // <string_view>
12 
13 // constexpr basic_string_view () noexcept;
14 
15 #include <string_view>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 
20 template<typename T>
test()21 void test () {
22 #if TEST_STD_VER > 11
23     {
24     ASSERT_NOEXCEPT(T());
25 
26     constexpr T sv1;
27     static_assert ( sv1.size() == 0, "" );
28     static_assert ( sv1.empty(), "");
29     }
30 #endif
31 
32     {
33     T sv1;
34     assert ( sv1.size() == 0 );
35     assert ( sv1.empty());
36     }
37 }
38 
main()39 int main () {
40     test<std::string_view> ();
41     test<std::u16string_view> ();
42 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
43     test<std::u8string_view> ();
44 #endif
45     test<std::u32string_view> ();
46     test<std::wstring_view> ();
47 
48 }
49