1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <string_view> 10 11 // constexpr basic_string_view () noexcept; 12 13 #include <string_view> 14 #include <cassert> 15 16 #include "test_macros.h" 17 18 template<typename T> 19 void test () { 20 #if TEST_STD_VER > 11 21 { 22 ASSERT_NOEXCEPT(T()); 23 24 constexpr T sv1; 25 static_assert ( sv1.size() == 0, "" ); 26 static_assert ( sv1.empty(), ""); 27 } 28 #endif 29 30 { 31 T sv1; 32 assert ( sv1.size() == 0 ); 33 assert ( sv1.empty()); 34 } 35 } 36 37 int main(int, char**) { 38 test<std::string_view> (); 39 test<std::u16string_view> (); 40 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L 41 test<std::u8string_view> (); 42 #endif 43 test<std::u32string_view> (); 44 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 45 test<std::wstring_view> (); 46 #endif 47 48 return 0; 49 } 50