[libcxx] adds concept `std::common_with`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96683

GitOrigin-RevId: f893312c1a6a67075f2f38b22e8fd866f0d3d9db
diff --git a/include/concepts b/include/concepts
index a644325..f13b18f 100644
--- a/include/concepts
+++ b/include/concepts
@@ -180,6 +180,23 @@
   convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
   convertible_to<_Up, common_reference_t<_Tp, _Up>>;
 
+// [concept.common]
+template<class _Tp, class _Up>
+concept common_with =
+  same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
+  requires {
+    static_cast<common_type_t<_Tp, _Up>>(_VSTD::declval<_Tp>());
+    static_cast<common_type_t<_Tp, _Up>>(_VSTD::declval<_Up>());
+  } &&
+  common_reference_with<
+    add_lvalue_reference_t<const _Tp>,
+    add_lvalue_reference_t<const _Up>> &&
+  common_reference_with<
+    add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
+    common_reference_t<
+      add_lvalue_reference_t<const _Tp>,
+      add_lvalue_reference_t<const _Up>>>;
+
 // [concepts.arithmetic], arithmetic concepts
 template<class _Tp>
 concept integral = is_integral_v<_Tp>;