xref: /freebsd/contrib/llvm-project/libcxx/include/__ranges/enable_view.h (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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 <__config>
14 #include <concepts>
15 #include <type_traits>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #  pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if _LIBCPP_STD_VER > 17
24 
25 namespace ranges {
26 
27 struct view_base { };
28 
29 template<class _Derived>
30   requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
31 class view_interface;
32 
33 template<class _Op, class _Yp>
34   requires is_convertible_v<_Op*, view_interface<_Yp>*>
35 void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*);
36 
37 template <class _Tp>
38 inline constexpr bool enable_view = derived_from<_Tp, view_base> ||
39   requires { ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); };
40 
41 } // namespace ranges
42 
43 #endif // _LIBCPP_STD_VER > 17
44 
45 _LIBCPP_END_NAMESPACE_STD
46 
47 #endif // _LIBCPP___RANGES_ENABLE_VIEW_H
48