Files
clang-p2996/libcxx/test/std/ranges/range.utility/range.subrange/ctad.compile.pass.cpp
Louis Dionne 6900df37d2 [libc++] Remove Lit annotations for unsupported GCC versions from the test suite
Since we officially don't support several older compilers now, we can
drop a lot of the markup in the test suite. This helps keep the test
suite simple and makes sure that UNSUPPORTED annotations don't rot.

This is the first patch of a series that will remove annotations for
compilers that are now unsupported.

Differential Revision: https://reviews.llvm.org/D107787
2021-08-12 13:30:47 -04:00

52 lines
2.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
// class std::ranges::subrange;
#include <ranges>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
using FI = forward_iterator<int*>;
FI fi{nullptr};
int *ptr = nullptr;
static_assert(std::same_as<decltype(std::ranges::subrange(fi, fi)),
std::ranges::subrange<FI, FI, std::ranges::subrange_kind::unsized>>);
static_assert(std::same_as<decltype(std::ranges::subrange(ptr, ptr, 0)),
std::ranges::subrange<int*, int*, std::ranges::subrange_kind::sized>>);
static_assert(std::same_as<decltype(std::ranges::subrange(ptr, nullptr, 0)),
std::ranges::subrange<int*, nullptr_t, std::ranges::subrange_kind::sized>>);
struct ForwardRange {
forward_iterator<int*> begin() const;
forward_iterator<int*> end() const;
};
template<>
inline constexpr bool std::ranges::enable_borrowed_range<ForwardRange> = true;
struct SizedRange {
int *begin();
int *end();
};
template<>
inline constexpr bool std::ranges::enable_borrowed_range<SizedRange> = true;
static_assert(std::same_as<decltype(std::ranges::subrange(ForwardRange())),
std::ranges::subrange<FI, FI, std::ranges::subrange_kind::unsized>>);
static_assert(std::same_as<decltype(std::ranges::subrange(SizedRange())),
std::ranges::subrange<int*, int*, std::ranges::subrange_kind::sized>>);
static_assert(std::same_as<decltype(std::ranges::subrange(SizedRange(), 8)),
std::ranges::subrange<int*, int*, std::ranges::subrange_kind::sized>>);