1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
11#define _LIBCPP___RANGES_ENABLE_VIEW_H
12
13#include <__concepts/derived_from.h>
14#include <__concepts/same_as.h>
15#include <__config>
16#include <__type_traits/is_class.h>
17#include <__type_traits/remove_cv.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER >= 20
26
27namespace ranges {
28
29struct view_base {};
30
31template <class _Derived>
32 requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
33class view_interface;
34
35template <class _Op, class _Yp>
36 requires(!same_as<_Op, view_interface<_Yp>>)
37void __is_derived_from_view_interface(view_interface<_Yp>*);
38
39template <class _Tp>
40inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires {
41 ranges::__is_derived_from_view_interface<remove_cv_t<_Tp>>((remove_cv_t<_Tp>*)nullptr);
42};
43
44} // namespace ranges
45
46#endif // _LIBCPP_STD_VER >= 20
47
48_LIBCPP_END_NAMESPACE_STD
49
50#endif // _LIBCPP___RANGES_ENABLE_VIEW_H
51