Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 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 | |
Stephan T. Lavavej | 0f901c7 | 2016-11-04 20:26:59 +0000 | [diff] [blame] | 18 | #include "test_macros.h" |
| 19 | |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 20 | template<typename T> |
| 21 | void test () { |
Stephan T. Lavavej | 0f901c7 | 2016-11-04 20:26:59 +0000 | [diff] [blame] | 22 | #if TEST_STD_VER > 11 |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 23 | { |
Marshall Clow | ac2b3e3 | 2017-10-24 16:30:06 +0000 | [diff] [blame] | 24 | ASSERT_NOEXCEPT(T()); |
| 25 | |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 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 | |
| 39 | int main () { |
| 40 | typedef std::string_view string_view; |
| 41 | typedef std::u16string_view u16string_view; |
| 42 | typedef std::u32string_view u32string_view; |
| 43 | typedef std::wstring_view wstring_view; |
| 44 | |
| 45 | test<string_view> (); |
| 46 | test<u16string_view> (); |
| 47 | test<u32string_view> (); |
| 48 | test<wstring_view> (); |
| 49 | |
| 50 | } |