enable_view.h 1.3 KB

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