summaryrefslogtreecommitdiff
path: root/libcxx/test/std/utilities/optional/optional.iterator/borrowed_range.compile.pass.cpp
blob: a79d1d51a5b11ca078651bc17b13c7b3305f8717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// REQUIRES: std-at-least-c++26

// <optional>

// template <class T> class optional<T&>::iterator;
// template <class T> class optional<T&>::const_iterator;
// template <class T>
// constexpr bool ranges::enable_borrowed_range<optional<T&>> = true;

#include <cassert>
#include <optional>
#include <ranges>

template <typename T>
void borrowed_range() {
  static_assert(std::ranges::enable_borrowed_range<std::optional<T&>>);
  static_assert(std::ranges::range<std::optional<T&>> == std::ranges::borrowed_range<std::optional<T&>>);
}

void test_borrowed_range() {
  borrowed_range<int>();
  borrowed_range<const int>();
  borrowed_range<int[]>();
  borrowed_range<int[10]>();
  borrowed_range<int()>();
}