[llvm][llvm-readobj] Add NT_ARM_GCS Linux core note type (#117545)
[llvm-project.git] / libcxx / test / std / ranges / range.factories / range.iota.view / ctor.value.pass.cpp
blobcda372e1b7a35cfcc3795088cfaf8b2c829a2a87
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 explicit iota_view(W value);
13 #include <cassert>
14 #include <ranges>
15 #include <type_traits>
17 #include "test_macros.h"
18 #include "types.h"
20 struct SomeIntComparable {
21 using difference_type = int;
23 SomeInt value_;
24 constexpr SomeIntComparable() : value_(SomeInt(10)) {}
26 friend constexpr bool operator==(SomeIntComparable lhs, SomeIntComparable rhs) {
27 return lhs.value_ == rhs.value_;
29 friend constexpr bool operator==(SomeIntComparable lhs, SomeInt rhs) {
30 return lhs.value_ == rhs;
32 friend constexpr bool operator==(SomeInt lhs, SomeIntComparable rhs) {
33 return lhs == rhs.value_;
36 friend constexpr difference_type operator-(SomeIntComparable lhs, SomeIntComparable rhs) {
37 return lhs.value_ - rhs.value_;
40 constexpr SomeIntComparable& operator++() { ++value_; return *this; }
41 constexpr SomeIntComparable operator++(int) { auto tmp = *this; ++value_; return tmp; }
42 constexpr SomeIntComparable operator--() { --value_; return *this; }
45 constexpr bool test() {
47 std::ranges::iota_view<SomeInt> io(SomeInt(42));
48 assert((*io.begin()).value_ == 42);
49 // Check that end returns std::unreachable_sentinel.
50 assert(io.end() != io.begin());
51 static_assert(std::same_as<decltype(io.end()), std::unreachable_sentinel_t>);
55 std::ranges::iota_view<SomeInt, SomeIntComparable> io(SomeInt(0));
56 assert(std::ranges::next(io.begin(), 10) == io.end());
59 static_assert(!std::is_convertible_v<std::ranges::iota_view<SomeInt>, SomeInt>);
60 static_assert( std::is_constructible_v<std::ranges::iota_view<SomeInt>, SomeInt>);
63 return true;
66 int main(int, char**) {
67 test();
68 static_assert(test());
70 return 0;