Skip to content

Commit

Permalink
[libc++] Granularize <type_traits> includes in <concepts>
Browse files Browse the repository at this point in the history
Reviewed By: ldionne, Mordante, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D139189
  • Loading branch information
philnik777 committed Dec 20, 2022
1 parent 011cbb3 commit 66ba7c3
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 22 deletions.
4 changes: 3 additions & 1 deletion libcxx/include/__concepts/arithmetic.h
Expand Up @@ -10,9 +10,11 @@
#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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/assignable.h
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/__concepts/class_or_enum.h
Expand Up @@ -10,7 +10,10 @@
#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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/common_reference_with.h
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/__concepts/common_with.h
Expand Up @@ -12,7 +12,10 @@
#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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/constructible.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/convertible_to.h
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__concepts/derived_from.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/destructible.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/different_from.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/equality_comparable.h
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__concepts/invocable.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/movable.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/predicate.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__concepts/same_as.h
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion libcxx/include/__concepts/swappable.h
Expand Up @@ -14,11 +14,15 @@
#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
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__concepts/totally_ordered.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__type_traits/is_nothrow_constructible.h
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__type_traits/is_signed.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__type_traits/remove_cvref.h
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion libcxx/include/__utility/swap.h
Expand Up @@ -10,10 +10,14 @@
#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
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/concepts
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/module.modulemap.in
Expand Up @@ -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" }
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/sstream
Expand Up @@ -876,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)

This comment has been minimized.

Copy link
@zhanhb

zhanhb Apr 3, 2023

_LIPCPP_REMOVE_TRANSITIVE_INCLUDES?
should it be _LIBCPP_REMOVE_TRANSITIVE_INCLUDES?
or it's better to rename to _LIBCPP_ABI_REMOVE_TRANSITIVE_INCLUDES?

# include <type_traits>
#endif

#endif // _LIBCPP_SSTREAM
Expand Up @@ -10,9 +10,10 @@

// 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>);
Expand All @@ -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(*)()>);

0 comments on commit 66ba7c3

Please sign in to comment.