common_with.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 > 17
  22. // [concept.common]
  23. template<class _Tp, class _Up>
  24. concept common_with =
  25. same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
  26. requires {
  27. static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
  28. static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
  29. } &&
  30. common_reference_with<
  31. add_lvalue_reference_t<const _Tp>,
  32. add_lvalue_reference_t<const _Up>> &&
  33. common_reference_with<
  34. add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
  35. common_reference_t<
  36. add_lvalue_reference_t<const _Tp>,
  37. add_lvalue_reference_t<const _Up>>>;
  38. #endif // _LIBCPP_STD_VER > 17
  39. _LIBCPP_END_NAMESPACE_STD
  40. #endif // _LIBCPP___CONCEPTS_COMMON_WITH_H