blob: 07a453b2369bcc29040f31374c53ef021f2da0b9 [file] [log] [blame]
Marshall Clow053d81c2016-07-21 05:31:24 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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
Marshall Clow053d81c2016-07-21 05:31:24 +00006//
7//===----------------------------------------------------------------------===//
8
9
10// <string_view>
11
12// constexpr basic_string_view () noexcept;
13
14#include <string_view>
15#include <cassert>
16
Stephan T. Lavavej0f901c72016-11-04 20:26:59 +000017#include "test_macros.h"
18
Marshall Clow053d81c2016-07-21 05:31:24 +000019template<typename T>
20void test () {
Stephan T. Lavavej0f901c72016-11-04 20:26:59 +000021#if TEST_STD_VER > 11
Marshall Clow053d81c2016-07-21 05:31:24 +000022 {
Marshall Clowac2b3e32017-10-24 16:30:06 +000023 ASSERT_NOEXCEPT(T());
24
Marshall Clow053d81c2016-07-21 05:31:24 +000025 constexpr T sv1;
26 static_assert ( sv1.size() == 0, "" );
27 static_assert ( sv1.empty(), "");
28 }
29#endif
30
31 {
32 T sv1;
33 assert ( sv1.size() == 0 );
34 assert ( sv1.empty());
35 }
36}
37
JF Bastien2df59c52019-02-04 20:31:13 +000038int main(int, char**) {
Marshall Clow7dad0bd2018-12-11 04:35:44 +000039 test<std::string_view> ();
40 test<std::u16string_view> ();
41#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
42 test<std::u8string_view> ();
43#endif
44 test<std::u32string_view> ();
45 test<std::wstring_view> ();
Marshall Clow053d81c2016-07-21 05:31:24 +000046
JF Bastien2df59c52019-02-04 20:31:13 +000047
48 return 0;
Marshall Clow053d81c2016-07-21 05:31:24 +000049}