Skip to content

Commit 7ae66e5

Browse files
committed
[libc++] Granularize the rest of type_traits
Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D130471
1 parent 2a46255 commit 7ae66e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+775
-403
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ set(files
332332
__functional/unary_negate.h
333333
__functional/unwrap_ref.h
334334
__functional/weak_result_type.h
335+
__fwd/hash.h
336+
__fwd/pair.h
335337
__fwd/span.h
336338
__fwd/string_view.h
337339
__hash_table
@@ -518,13 +520,15 @@ set(files
518520
__type_traits/aligned_union.h
519521
__type_traits/alignment_of.h
520522
__type_traits/apply_cv.h
523+
__type_traits/can_extract_key.h
521524
__type_traits/common_reference.h
522525
__type_traits/common_type.h
523526
__type_traits/conditional.h
524527
__type_traits/conjunction.h
525528
__type_traits/copy_cv.h
526529
__type_traits/copy_cvref.h
527530
__type_traits/decay.h
531+
__type_traits/dependent_type.h
528532
__type_traits/disjunction.h
529533
__type_traits/enable_if.h
530534
__type_traits/extent.h
@@ -539,6 +543,7 @@ set(files
539543
__type_traits/is_base_of.h
540544
__type_traits/is_bounded_array.h
541545
__type_traits/is_callable.h
546+
__type_traits/is_char_like_type.h
542547
__type_traits/is_class.h
543548
__type_traits/is_compound.h
544549
__type_traits/is_const.h
@@ -556,6 +561,7 @@ set(files
556561
__type_traits/is_floating_point.h
557562
__type_traits/is_function.h
558563
__type_traits/is_fundamental.h
564+
__type_traits/is_implicitly_default_constructible.h
559565
__type_traits/is_integral.h
560566
__type_traits/is_literal_type.h
561567
__type_traits/is_member_function_pointer.h
@@ -587,6 +593,7 @@ set(files
587593
__type_traits/is_signed.h
588594
__type_traits/is_signed_integer.h
589595
__type_traits/is_standard_layout.h
596+
__type_traits/is_swappable.h
590597
__type_traits/is_trivial.h
591598
__type_traits/is_trivially_assignable.h
592599
__type_traits/is_trivially_constructible.h
@@ -606,20 +613,24 @@ set(files
606613
__type_traits/is_volatile.h
607614
__type_traits/lazy.h
608615
__type_traits/make_32_64_or_128_bit.h
616+
__type_traits/make_const_lvalue_ref.h
609617
__type_traits/make_signed.h
610618
__type_traits/make_unsigned.h
619+
__type_traits/maybe_const.h
611620
__type_traits/nat.h
612621
__type_traits/negation.h
613622
__type_traits/promote.h
614623
__type_traits/rank.h
615624
__type_traits/remove_all_extents.h
616625
__type_traits/remove_const.h
626+
__type_traits/remove_const_ref.h
617627
__type_traits/remove_cv.h
618628
__type_traits/remove_cvref.h
619629
__type_traits/remove_extent.h
620630
__type_traits/remove_pointer.h
621631
__type_traits/remove_reference.h
622632
__type_traits/remove_volatile.h
633+
__type_traits/result_of.h
623634
__type_traits/type_identity.h
624635
__type_traits/type_list.h
625636
__type_traits/underlying_type.h
@@ -628,6 +639,7 @@ set(files
628639
__utility/as_const.h
629640
__utility/auto_cast.h
630641
__utility/cmp.h
642+
__utility/convert_to_integral.h
631643
__utility/declval.h
632644
__utility/exchange.h
633645
__utility/forward.h

libcxx/include/__algorithm/copy_backward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <__ranges/subrange.h>
2121
#include <__utility/move.h>
2222
#include <__utility/pair.h>
23+
#include <cstring>
2324
#include <type_traits>
2425

2526
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__algorithm/copy_n.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <__algorithm/copy.h>
1313
#include <__config>
1414
#include <__iterator/iterator_traits.h>
15+
#include <__utility/convert_to_integral.h>
1516
#include <type_traits>
1617

1718
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__algorithm/fill_n.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <__config>
1313
#include <__iterator/iterator_traits.h>
14+
#include <__utility/convert_to_integral.h>
1415
#include <type_traits>
1516

1617
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__algorithm/for_each_n.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
1212

1313
#include <__config>
14+
#include <__utility/convert_to_integral.h>
1415
#include <type_traits>
1516

1617
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__algorithm/generate_n.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _LIBCPP___ALGORITHM_GENERATE_N_H
1111

1212
#include <__config>
13+
#include <__utility/convert_to_integral.h>
1314
#include <type_traits>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__algorithm/search_n.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <__iterator/distance.h>
2020
#include <__iterator/iterator_traits.h>
2121
#include <__ranges/concepts.h>
22+
#include <__utility/convert_to_integral.h>
2223
#include <__utility/pair.h>
2324
#include <type_traits> // __convert_to_integral
2425

libcxx/include/__compare/compare_three_way_result.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
1111

1212
#include <__config>
13+
#include <__type_traits/make_const_lvalue_ref.h>
1314
#include <type_traits>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__compare/three_way_comparable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <__concepts/same_as.h>
1717
#include <__concepts/totally_ordered.h>
1818
#include <__config>
19+
#include <__type_traits/make_const_lvalue_ref.h>
1920
#include <type_traits>
2021

2122
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__concepts/assignable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <__concepts/common_reference_with.h>
1313
#include <__concepts/same_as.h>
1414
#include <__config>
15+
#include <__type_traits/make_const_lvalue_ref.h>
1516
#include <__utility/forward.h>
1617
#include <type_traits>
1718

libcxx/include/__concepts/equality_comparable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <__concepts/boolean_testable.h>
1313
#include <__concepts/common_reference_with.h>
1414
#include <__config>
15+
#include <__type_traits/make_const_lvalue_ref.h>
1516
#include <type_traits>
1617

1718
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__concepts/swappable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <__utility/exchange.h>
1818
#include <__utility/forward.h>
1919
#include <__utility/move.h>
20+
#include <__utility/swap.h>
2021
#include <type_traits>
2122

2223
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__functional/hash.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <__config>
1313
#include <__functional/unary_function.h>
14+
#include <__fwd/hash.h>
1415
#include <__tuple>
1516
#include <__utility/forward.h>
1617
#include <__utility/move.h>

libcxx/include/__fwd/hash.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===---------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_HASH_H
10+
#define _LIBCPP___FWD_HASH_H
11+
12+
#include <__config>
13+
14+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15+
# pragma GCC system_header
16+
#endif
17+
18+
_LIBCPP_BEGIN_NAMESPACE_STD
19+
20+
template <class>
21+
struct _LIBCPP_TEMPLATE_VIS hash;
22+
23+
_LIBCPP_END_NAMESPACE_STD
24+
25+
#endif // _LIBCPP___FWD_HASH_H

libcxx/include/__fwd/pair.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===---------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_PAIR_H
10+
#define _LIBCPP___FWD_PAIR_H
11+
12+
#include <__config>
13+
14+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15+
# pragma GCC system_header
16+
#endif
17+
18+
_LIBCPP_BEGIN_NAMESPACE_STD
19+
20+
template <class, class>
21+
struct _LIBCPP_TEMPLATE_VIS pair;
22+
23+
_LIBCPP_END_NAMESPACE_STD
24+
25+
#endif // _LIBCPP___FWD_PAIR_H

libcxx/include/__fwd/span.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===---------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_FWD_SPAN_H
11-
#define _LIBCPP_FWD_SPAN_H
10+
#ifndef _LIBCPP___FWD_SPAN_H
11+
#define _LIBCPP___FWD_SPAN_H
1212

1313
#include <__config>
1414
#include <cstddef>
@@ -34,4 +34,4 @@ _LIBCPP_END_NAMESPACE_STD
3434

3535
_LIBCPP_POP_MACROS
3636

37-
#endif // _LIBCPP_FWD_SPAN_H
37+
#endif // _LIBCPP___FWD_SPAN_H

libcxx/include/__fwd/string_view.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===---------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_FWD_STRING_VIEW_H
11-
#define _LIBCPP_FWD_STRING_VIEW_H
10+
#ifndef _LIBCPP___FWD_STRING_VIEW_H
11+
#define _LIBCPP___FWD_STRING_VIEW_H
1212

1313
#include <__config>
1414
#include <iosfwd> // char_traits
@@ -34,4 +34,4 @@ typedef basic_string_view<wchar_t> wstring_view;
3434

3535
_LIBCPP_END_NAMESPACE_STD
3636

37-
#endif // _LIBCPP_FWD_STRING_VIEW_H
37+
#endif // _LIBCPP___FWD_STRING_VIEW_H

libcxx/include/__hash_table

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <__functional/hash.h>
2020
#include <__iterator/iterator_traits.h>
2121
#include <__memory/swap_allocator.h>
22+
#include <__type_traits/can_extract_key.h>
2223
#include <__utility/swap.h>
2324
#include <cmath>
2425
#include <initializer_list>

libcxx/include/__iterator/advance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <__iterator/concepts.h>
1616
#include <__iterator/incrementable_traits.h>
1717
#include <__iterator/iterator_traits.h>
18+
#include <__utility/convert_to_integral.h>
1819
#include <__utility/move.h>
1920
#include <__utility/unreachable.h>
2021
#include <concepts>

libcxx/include/__iterator/iterator_traits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
1212

1313
#include <__config>
14+
#include <__fwd/pair.h>
1415
#include <__iterator/incrementable_traits.h>
1516
#include <__iterator/readable_traits.h>
1617
#include <concepts>

libcxx/include/__memory/compressed_pair.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
1212

1313
#include <__config>
14+
#include <__type_traits/dependent_type.h>
1415
#include <__utility/forward.h>
1516
#include <__utility/move.h>
1617
#include <tuple> // needed in c++03 for some constructors

libcxx/include/__ranges/join_view.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <__ranges/non_propagating_cache.h>
2626
#include <__ranges/range_adaptor.h>
2727
#include <__ranges/view_interface.h>
28+
#include <__type_traits/maybe_const.h>
2829
#include <__utility/forward.h>
2930
#include <optional>
3031
#include <type_traits>
@@ -210,7 +211,7 @@ namespace ranges {
210211

211212
public:
212213
using iterator_concept = _If<
213-
__ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
214+
__ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
214215
common_range<range_reference_t<_Base>>,
215216
bidirectional_iterator_tag,
216217
_If<
@@ -345,7 +346,7 @@ namespace ranges {
345346

346347
template<class _Range>
347348
explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
348-
349+
349350
namespace views {
350351
namespace __join_view {
351352
struct __fn : __range_adaptor_closure<__fn> {

libcxx/include/__ranges/lazy_split_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <__ranges/single_view.h>
3636
#include <__ranges/subrange.h>
3737
#include <__ranges/view_interface.h>
38+
#include <__type_traits/maybe_const.h>
3839
#include <__utility/forward.h>
3940
#include <__utility/move.h>
4041
#include <type_traits>

libcxx/include/__ranges/take_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <__ranges/size.h>
3131
#include <__ranges/subrange.h>
3232
#include <__ranges/view_interface.h>
33+
#include <__type_traits/maybe_const.h>
3334
#include <__utility/auto_cast.h>
3435
#include <__utility/forward.h>
3536
#include <__utility/move.h>

libcxx/include/__ranges/transform_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <__ranges/range_adaptor.h>
3131
#include <__ranges/size.h>
3232
#include <__ranges/view_interface.h>
33+
#include <__type_traits/maybe_const.h>
3334
#include <__utility/forward.h>
3435
#include <__utility/in_place.h>
3536
#include <__utility/move.h>

libcxx/include/__threading_support

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <__chrono/duration.h>
1616
#include <__compare/ordering.h>
1717
#include <__config>
18+
#include <__fwd/hash.h>
1819
#include <__thread/poll_with_backoff.h>
1920
#include <errno.h>
2021
#include <iosfwd>

libcxx/include/__tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <__iterator/iterator_traits.h>
1919
#include <__iterator/next.h>
2020
#include <__memory/swap_allocator.h>
21+
#include <__type_traits/can_extract_key.h>
2122
#include <__utility/forward.h>
2223
#include <__utility/swap.h>
2324
#include <limits>

libcxx/include/__tuple

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___TUPLE
1212

1313
#include <__config>
14+
#include <__fwd/pair.h>
1415
#include <cstddef>
1516
#include <type_traits>
1617

0 commit comments

Comments
 (0)