enable_view.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
  10. #define _LIBCPP___RANGES_ENABLE_VIEW_H
  11. #include <__concepts/derived_from.h>
  12. #include <__concepts/same_as.h>
  13. #include <__config>
  14. #include <__type_traits/is_class.h>
  15. #include <__type_traits/is_convertible.h>
  16. #include <__type_traits/remove_cv.h>
  17. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  18. # pragma GCC system_header
  19. #endif
  20. _LIBCPP_BEGIN_NAMESPACE_STD
  21. #if _LIBCPP_STD_VER >= 20
  22. namespace ranges {
  23. struct view_base {};
  24. template <class _Derived>
  25. requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
  26. class view_interface;
  27. template <class _Op, class _Yp>
  28. requires is_convertible_v<_Op*, view_interface<_Yp>*>
  29. void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*);
  30. template <class _Tp>
  31. inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires {
  32. ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr);
  33. };
  34. } // namespace ranges
  35. #endif // _LIBCPP_STD_VER >= 20
  36. _LIBCPP_END_NAMESPACE_STD
  37. #endif // _LIBCPP___RANGES_ENABLE_VIEW_H