| 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 |
// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 |
|
| 11 |
// template <class _Tp> |
| 12 |
// inline constexpr empty_view<_Tp> empty{}; |
| 13 |
|
| 14 |
#include <ranges> |
| 15 |
#include <cassert> |
| 16 |
|
| 17 |
#include "test_macros.h" |
| 18 |
|
| 19 |
template <class T> |
| 20 |
constexpr void testType() { |
| 21 |
ASSERT_SAME_TYPE(decltype(std::views::empty<T>), const std::ranges::empty_view<T>); |
| 22 |
ASSERT_SAME_TYPE(decltype((std::views::empty<T>)), const std::ranges::empty_view<T>&); |
| 23 |
|
| 24 |
auto v = std::views::empty<T>; |
| 25 |
assert(std::ranges::empty(v)); |
| 26 |
} |
| 27 |
|
| 28 |
struct Empty {}; |
| 29 |
struct BigType { |
| 30 |
char buff[8]; |
| 31 |
}; |
| 32 |
|
| 33 |
constexpr bool test() { |
| 34 |
|
| 35 |
testType<int>(); |
| 36 |
testType<const int>(); |
| 37 |
testType<int*>(); |
| 38 |
testType<Empty>(); |
| 39 |
testType<const Empty>(); |
| 40 |
testType<BigType>(); |
| 41 |
|
| 42 |
return true; |
| 43 |
} |
| 44 |
|
| 45 |
int main(int, char**) { |
| 46 |
test(); |
| 47 |
static_assert(test()); |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |