default.pass.cpp 1.0 KB

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