brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · a2d7660 Raw
51 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 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 19template <class T>20constexpr 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 28struct Empty {};29struct BigType {30  char buff[8];31};32 33constexpr 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 45int main(int, char**) {46  test();47  static_assert(test());48 49  return 0;50}51