common_with.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef _LIBCPP___CONCEPTS_COMMON_WITH_H
  9. #define _LIBCPP___CONCEPTS_COMMON_WITH_H
  10. #include <__concepts/common_reference_with.h>
  11. #include <__concepts/same_as.h>
  12. #include <__config>
  13. #include <__type_traits/add_lvalue_reference.h>
  14. #include <__type_traits/common_reference.h>
  15. #include <__type_traits/common_type.h>
  16. #include <__utility/declval.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. // [concept.common]
  23. // clang-format off
  24. template <class _Tp, class _Up>
  25. concept common_with =
  26. same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
  27. requires {
  28. static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
  29. static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
  30. } &&
  31. common_reference_with<
  32. add_lvalue_reference_t<const _Tp>,
  33. add_lvalue_reference_t<const _Up>> &&
  34. common_reference_with<
  35. add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
  36. common_reference_t<
  37. add_lvalue_reference_t<const _Tp>,
  38. add_lvalue_reference_t<const _Up>>>;
  39. // clang-format on
  40. #endif // _LIBCPP_STD_VER >= 20
  41. _LIBCPP_END_NAMESPACE_STD
  42. #endif // _LIBCPP___CONCEPTS_COMMON_WITH_H