xref: /llvm-project/libcxx/include/__concepts/common_with.h (revision 5aa03b648b827128d439f705cd7d57d59673741d)
158915667SArthur O'Dwyer //===----------------------------------------------------------------------===//
258915667SArthur O'Dwyer //
358915667SArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
458915667SArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information.
558915667SArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
658915667SArthur O'Dwyer //
758915667SArthur O'Dwyer //===----------------------------------------------------------------------===//
858915667SArthur O'Dwyer 
958915667SArthur O'Dwyer #ifndef _LIBCPP___CONCEPTS_COMMON_WITH_H
1058915667SArthur O'Dwyer #define _LIBCPP___CONCEPTS_COMMON_WITH_H
1158915667SArthur O'Dwyer 
1258915667SArthur O'Dwyer #include <__concepts/common_reference_with.h>
1358915667SArthur O'Dwyer #include <__concepts/same_as.h>
1458915667SArthur O'Dwyer #include <__config>
1566ba7c32SNikolas Klauser #include <__type_traits/add_lvalue_reference.h>
1666ba7c32SNikolas Klauser #include <__type_traits/common_reference.h>
1766ba7c32SNikolas Klauser #include <__type_traits/common_type.h>
1866ba7c32SNikolas Klauser #include <__utility/declval.h>
1958915667SArthur O'Dwyer 
2058915667SArthur O'Dwyer #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2158915667SArthur O'Dwyer #  pragma GCC system_header
2258915667SArthur O'Dwyer #endif
2358915667SArthur O'Dwyer 
2458915667SArthur O'Dwyer _LIBCPP_BEGIN_NAMESPACE_STD
2558915667SArthur O'Dwyer 
264f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 20
2758915667SArthur O'Dwyer 
2858915667SArthur O'Dwyer // [concept.common]
2958915667SArthur O'Dwyer 
30*5aa03b64SLouis Dionne // clang-format off
3158915667SArthur O'Dwyer template <class _Tp, class _Up>
3258915667SArthur O'Dwyer concept common_with =
3358915667SArthur O'Dwyer     same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
3458915667SArthur O'Dwyer     requires {
3573e8e1baSNikolas Klauser         static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
3673e8e1baSNikolas Klauser         static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
3758915667SArthur O'Dwyer     } &&
3858915667SArthur O'Dwyer     common_reference_with<
3958915667SArthur O'Dwyer         add_lvalue_reference_t<const _Tp>,
4058915667SArthur O'Dwyer         add_lvalue_reference_t<const _Up>> &&
4158915667SArthur O'Dwyer     common_reference_with<
4258915667SArthur O'Dwyer         add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
4358915667SArthur O'Dwyer         common_reference_t<
4458915667SArthur O'Dwyer             add_lvalue_reference_t<const _Tp>,
4558915667SArthur O'Dwyer             add_lvalue_reference_t<const _Up>>>;
46*5aa03b64SLouis Dionne // clang-format on
4758915667SArthur O'Dwyer 
484f15267dSNikolas Klauser #endif // _LIBCPP_STD_VER >= 20
4958915667SArthur O'Dwyer 
5058915667SArthur O'Dwyer _LIBCPP_END_NAMESPACE_STD
5158915667SArthur O'Dwyer 
5258915667SArthur O'Dwyer #endif // _LIBCPP___CONCEPTS_COMMON_WITH_H
53