[libc++] Fix conjunction/disjunction and mark a few LWG issues as complete
Fixes #54803
Fixes #53133
Reviewed By: ldionne, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D125221
NOKEYCHECK=True
GitOrigin-RevId: a29a1a33ac7b567031e5995cc0f17784a1c4be7a
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 4931ec8..4cb717e 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -449,7 +449,9 @@
__type_traits/add_rvalue_reference.h
__type_traits/add_volatile.h
__type_traits/conditional.h
+ __type_traits/conjunction.h
__type_traits/decay.h
+ __type_traits/disjunction.h
__type_traits/enable_if.h
__type_traits/extent.h
__type_traits/integral_constant.h
diff --git a/include/__type_traits/conjunction.h b/include/__type_traits/conjunction.h
new file mode 100644
index 0000000..187b73e
--- /dev/null
+++ b/include/__type_traits/conjunction.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
+#define _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Arg, class... _Args>
+struct __conjunction_impl {
+ using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>;
+};
+
+template <class _Arg>
+struct __conjunction_impl<_Arg> {
+ using type = _Arg;
+};
+
+template <class... _Args>
+struct conjunction : __conjunction_impl<true_type, _Args...>::type {};
+
+template<class... _Args>
+inline constexpr bool conjunction_v = conjunction<_Args...>::value;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
diff --git a/include/__type_traits/disjunction.h b/include/__type_traits/disjunction.h
new file mode 100644
index 0000000..1f7c5fe
--- /dev/null
+++ b/include/__type_traits/disjunction.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
+#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Arg, class... _Args>
+struct __disjunction_impl {
+ using type = conditional_t<bool(_Arg::value), _Arg, typename __disjunction_impl<_Args...>::type>;
+};
+
+template <class _Arg>
+struct __disjunction_impl<_Arg> {
+ using type = _Arg;
+};
+
+template <class... _Args>
+struct disjunction : __disjunction_impl<false_type, _Args...>::type {};
+template<class... _Args>
+inline constexpr bool disjunction_v = disjunction<_Args...>::value;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
diff --git a/include/module.modulemap b/include/module.modulemap
index e24c387..c501137 100644
--- a/include/module.modulemap
+++ b/include/module.modulemap
@@ -996,7 +996,9 @@
module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" }
module add_volatile { private header "__type_traits/add_volatile.h" }
module conditional { private header "__type_traits/conditional.h" }
+ module conjunction { private header "__type_traits/conjunction.h" }
module decay { private header "__type_traits/decay.h" }
+ module disjunction { private header "__type_traits/disjunction.h" }
module enable_if { private header "__type_traits/enable_if.h" }
module extent { private header "__type_traits/extent.h" }
module integral_constant { private header "__type_traits/integral_constant.h" }
diff --git a/include/type_traits b/include/type_traits
index 852aed1..9e16987 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -425,7 +425,9 @@
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_volatile.h>
#include <__type_traits/conditional.h>
+#include <__type_traits/conjunction.h>
#include <__type_traits/decay.h>
+#include <__type_traits/disjunction.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/extent.h>
#include <__type_traits/integral_constant.h>
@@ -2872,17 +2874,6 @@
#endif
#if _LIBCPP_STD_VER > 14
-
-template <class... _Args>
-struct conjunction : _And<_Args...> {};
-template<class... _Args>
-inline constexpr bool conjunction_v = conjunction<_Args...>::value;
-
-template <class... _Args>
-struct disjunction : _Or<_Args...> {};
-template<class... _Args>
-inline constexpr bool disjunction_v = disjunction<_Args...>::value;
-
template <class _Tp>
struct negation : _Not<_Tp> {};
template<class _Tp>