[libc++] Granularize <type_traits> includes in <concepts>
authorNikolas Klauser <nikolasklauser@berlin.de>
Tue, 20 Dec 2022 17:01:34 +0000 (18:01 +0100)
committerNikolas Klauser <nikolasklauser@berlin.de>
Tue, 20 Dec 2022 20:37:39 +0000 (21:37 +0100)
Reviewed By: ldionne, Mordante, #libc

Spies: jloser, libcxx-commits

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

25 files changed:
libcxx/include/__concepts/arithmetic.h
libcxx/include/__concepts/assignable.h
libcxx/include/__concepts/class_or_enum.h
libcxx/include/__concepts/common_reference_with.h
libcxx/include/__concepts/common_with.h
libcxx/include/__concepts/constructible.h
libcxx/include/__concepts/convertible_to.h
libcxx/include/__concepts/derived_from.h
libcxx/include/__concepts/destructible.h
libcxx/include/__concepts/different_from.h
libcxx/include/__concepts/equality_comparable.h
libcxx/include/__concepts/invocable.h
libcxx/include/__concepts/movable.h
libcxx/include/__concepts/predicate.h
libcxx/include/__concepts/same_as.h
libcxx/include/__concepts/swappable.h
libcxx/include/__concepts/totally_ordered.h
libcxx/include/__type_traits/is_nothrow_constructible.h
libcxx/include/__type_traits/is_signed.h
libcxx/include/__type_traits/remove_cvref.h
libcxx/include/__utility/swap.h
libcxx/include/concepts
libcxx/include/module.modulemap.in
libcxx/include/sstream
libcxx/test/libcxx/ranges/range.utility.helpers/different_from.compile.pass.cpp

index d91570f..215b52a 100644 (file)
 #define _LIBCPP___CONCEPTS_ARITHMETIC_H
 
 #include <__config>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_signed.h>
 #include <__type_traits/is_signed_integer.h>
 #include <__type_traits/is_unsigned_integer.h>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index db09e5a..91edd40 100644 (file)
@@ -12,9 +12,9 @@
 #include <__concepts/common_reference_with.h>
 #include <__concepts/same_as.h>
 #include <__config>
+#include <__type_traits/is_reference.h>
 #include <__type_traits/make_const_lvalue_ref.h>
 #include <__utility/forward.h>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 6287c52..c4d2f98 100644 (file)
 #define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
 
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_union.h>
+#include <__type_traits/remove_cvref.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index cae2f5b..cc92762 100644 (file)
@@ -12,7 +12,7 @@
 #include <__concepts/convertible_to.h>
 #include <__concepts/same_as.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 1b5f4da..9bd8bf1 100644 (file)
 #include <__concepts/common_reference_with.h>
 #include <__concepts/same_as.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/common_type.h>
+#include <__utility/declval.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index aaf5154..1d78eb5 100644 (file)
@@ -12,7 +12,7 @@
 #include <__concepts/convertible_to.h>
 #include <__concepts/destructible.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_constructible.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 5d9d437..a1c2c3a 100644 (file)
@@ -10,8 +10,8 @@
 #define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
 
 #include <__config>
+#include <__type_traits/is_convertible.h>
 #include <__utility/declval.h>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 4b29147..0d3462d 100644 (file)
@@ -10,7 +10,8 @@
 #define _LIBCPP___CONCEPTS_DERIVED_FROM_H
 
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_convertible.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 90a043d..ad3819d 100644 (file)
@@ -10,7 +10,7 @@
 #define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
 
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_nothrow_destructible.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 3066372..15fd8f0 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <__concepts/same_as.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/remove_cvref.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index c2293d5..b865141 100644 (file)
@@ -12,8 +12,8 @@
 #include <__concepts/boolean_testable.h>
 #include <__concepts/common_reference_with.h>
 #include <__config>
+#include <__type_traits/common_reference.h>
 #include <__type_traits/make_const_lvalue_ref.h>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index d90389e..ec39b7b 100644 (file)
@@ -12,7 +12,6 @@
 #include <__config>
 #include <__functional/invoke.h>
 #include <__utility/forward.h>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 639219e..749b78a 100644 (file)
@@ -13,7 +13,7 @@
 #include <__concepts/constructible.h>
 #include <__concepts/swappable.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_object.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index cb23975..7ae9783 100644 (file)
@@ -12,7 +12,7 @@
 #include <__concepts/boolean_testable.h>
 #include <__concepts/invocable.h>
 #include <__config>
-#include <type_traits>
+#include <__functional/invoke.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 7654906..554ebc3 100644 (file)
@@ -10,7 +10,7 @@
 #define _LIBCPP___CONCEPTS_SAME_AS_H
 
 #include <__config>
-#include <type_traits>
+#include <__type_traits/is_same.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index dbb4283..d91a7a1 100644 (file)
 #include <__concepts/common_reference_with.h>
 #include <__concepts/constructible.h>
 #include <__config>
+#include <__type_traits/extent.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/remove_cvref.h>
 #include <__utility/exchange.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <__utility/swap.h>
-#include <type_traits>
+#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 2534779..f12d26b 100644 (file)
@@ -12,7 +12,8 @@
 #include <__concepts/boolean_testable.h>
 #include <__concepts/equality_comparable.h>
 #include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/make_const_lvalue_ref.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 6272298..4caad81 100644 (file)
@@ -14,6 +14,7 @@
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_reference.h>
 #include <__utility/declval.h>
+#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index e9722c9..aa42a4e 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <__config>
 #include <__type_traits/integral_constant.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_integral.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index e96cc65..faada28 100644 (file)
@@ -12,6 +12,7 @@
 #include <__config>
 #include <__type_traits/is_same.h>
 #include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
index 545614a..0843b35 100644 (file)
 #define _LIBCPP___UTILITY_SWAP_H
 
 #include <__config>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_swappable.h>
 #include <__utility/declval.h>
 #include <__utility/move.h>
 #include <cstddef>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 301256c..196fa2e 100644 (file)
@@ -155,6 +155,10 @@ namespace std {
 #include <__config>
 #include <version>
 
+#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
+#  include <type_traits>
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
index 4c3a09d..2a2064c 100644 (file)
@@ -1436,7 +1436,10 @@ module std [system] {
     module is_reference                        { private header "__type_traits/is_reference.h" }
     module is_reference_wrapper                { private header "__type_traits/is_reference_wrapper.h" }
     module is_referenceable                    { private header "__type_traits/is_referenceable.h" }
-    module is_same                             { private header "__type_traits/is_same.h" }
+    module is_same                             {
+      private header "__type_traits/is_same.h"
+      export type_traits.integral_constant
+    }
     module is_scalar                           { private header "__type_traits/is_scalar.h" }
     module is_scoped_enum                      { private header "__type_traits/is_scoped_enum.h" }
     module is_signed                           { private header "__type_traits/is_signed.h" }
index 91d1a07..20f9c60 100644 (file)
@@ -876,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS
 
+#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
+#  include <type_traits>
+#endif
+
 #endif // _LIBCPP_SSTREAM
index 2d594f4..f19c1ba 100644 (file)
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-#include <concepts>
+// Check that different_from.h is self-contained
+// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
 
-#include "test_macros.h"
+#include <__concepts/different_from.h>
 
 static_assert(std::__different_from<int, char>);
 static_assert(std::__different_from<const int, char>);
@@ -25,4 +26,3 @@ static_assert(!std::__different_from<int, int&>);
 static_assert(!std::__different_from<int&, const int&>);
 static_assert(!std::__different_from<int(&)(), int()>);
 static_assert(std::__different_from<int(&)(), int(*)()>);
-