42 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// constexpr sentinel_t<Base> base() const;12 13#include <cassert>14#include <ranges>15#include <tuple>16#include <type_traits>17#include <utility>18 19struct Sent {20 int i;21 22 friend constexpr bool operator==(std::tuple<int>*, const Sent&) { return true; }23};24 25constexpr bool test() {26 using BaseRange = std::ranges::subrange<std::tuple<int>*, Sent>;27 using EleRange = std::ranges::elements_view<BaseRange, 0>;28 using EleSent = std::ranges::sentinel_t<EleRange>;29 30 const EleSent st{Sent{5}};31 std::same_as<Sent> decltype(auto) base = st.base();32 assert(base.i == 5);33 34 return true;35}36 37int main(int, char**) {38 test();39 static_assert(test());40 return 0;41}42