[CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC...
[llvm-project.git] / libcxx / test / std / ranges / range.utility / range.subrange / ctor.default.pass.cpp
blobe1d3c643ce388f57de99a9cc9f3bb85d4b49eeff
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // constexpr subrange() requires default_initializable<I>;
13 #include <ranges>
15 #include <cassert>
16 #include <cstddef>
18 #include "test_iterators.h"
20 // An input_or_output_iterator that is not default constructible so we can test
21 // the `requires` on subrange's default constructor.
22 struct NoDefaultIterator {
23 using difference_type = std::ptrdiff_t;
24 NoDefaultIterator() = delete;
25 NoDefaultIterator& operator++();
26 void operator++(int);
27 int& operator*() const;
28 friend bool operator==(NoDefaultIterator const&, NoDefaultIterator const&);
30 static_assert(std::input_or_output_iterator<NoDefaultIterator>);
32 // A sentinel type for the above iterator
33 struct Sentinel {
34 friend bool operator==(NoDefaultIterator const&, Sentinel const&);
35 friend bool operator==(Sentinel const&, NoDefaultIterator const&);
36 friend bool operator!=(NoDefaultIterator const&, Sentinel const&);
37 friend bool operator!=(Sentinel const&, NoDefaultIterator const&);
40 constexpr bool test() {
42 static_assert(!std::is_default_constructible_v<std::ranges::subrange<NoDefaultIterator, Sentinel, std::ranges::subrange_kind::sized>>);
43 static_assert(!std::is_default_constructible_v<std::ranges::subrange<NoDefaultIterator, Sentinel, std::ranges::subrange_kind::unsized>>);
47 using Iter = forward_iterator<int*>;
48 std::ranges::subrange<Iter, Iter, std::ranges::subrange_kind::sized> subrange;
49 assert(subrange.begin() == Iter());
50 assert(subrange.end() == Iter());
53 using Iter = forward_iterator<int*>;
54 std::ranges::subrange<Iter, Iter, std::ranges::subrange_kind::unsized> subrange;
55 assert(subrange.begin() == Iter());
56 assert(subrange.end() == Iter());
59 return true;
62 int main(int, char**) {
63 test();
64 static_assert(test());
66 return 0;