Skip to content

Commit 33de5a3

Browse files
authored
[libc++] Rename __fwd/hash.h to __fwd/functional.h and add reference_wrapper (llvm#81445)
We forward declare `reference_wrapper` in multiple places already. This moves the declaration to the canonical place and removes unnecessary includes of `__functional/reference_wrapper.h`.
1 parent 0c90e88 commit 33de5a3

File tree

19 files changed

+20
-28
lines changed

19 files changed

+20
-28
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ set(files
431431
__fwd/bit_reference.h
432432
__fwd/complex.h
433433
__fwd/fstream.h
434-
__fwd/hash.h
434+
__fwd/functional.h
435435
__fwd/ios.h
436436
__fwd/istream.h
437437
__fwd/mdspan.h

libcxx/include/__filesystem/path.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
#include <__algorithm/replace_copy.h>
1515
#include <__availability>
1616
#include <__config>
17-
#include <__functional/hash.h>
1817
#include <__functional/unary_function.h>
19-
#include <__fwd/hash.h>
18+
#include <__fwd/functional.h>
2019
#include <__iterator/back_insert_iterator.h>
2120
#include <__iterator/iterator_traits.h>
2221
#include <__type_traits/decay.h>

libcxx/include/__functional/bind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <__config>
1414
#include <__functional/invoke.h>
1515
#include <__functional/weak_result_type.h>
16+
#include <__fwd/functional.h>
1617
#include <__type_traits/decay.h>
1718
#include <__type_traits/is_reference_wrapper.h>
1819
#include <__type_traits/is_void.h>

libcxx/include/__functional/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <__config>
1313
#include <__functional/invoke.h>
1414
#include <__functional/unary_function.h>
15-
#include <__fwd/hash.h>
15+
#include <__fwd/functional.h>
1616
#include <__tuple/sfinae_helpers.h>
1717
#include <__type_traits/is_copy_constructible.h>
1818
#include <__type_traits/is_default_constructible.h>

libcxx/include/__functional/identity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define _LIBCPP___FUNCTIONAL_IDENTITY_H
1212

1313
#include <__config>
14-
#include <__functional/reference_wrapper.h>
14+
#include <__fwd/functional.h>
1515
#include <__type_traits/integral_constant.h>
1616
#include <__utility/forward.h>
1717

libcxx/include/__fwd/hash.h renamed to libcxx/include/__fwd/functional.h

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

9-
#ifndef _LIBCPP___FWD_HASH_H
10-
#define _LIBCPP___FWD_HASH_H
9+
#ifndef _LIBCPP___FWD_FUNCTIONAL_H
10+
#define _LIBCPP___FWD_FUNCTIONAL_H
1111

1212
#include <__config>
1313

@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
template <class>
2121
struct _LIBCPP_TEMPLATE_VIS hash;
2222

23+
template <class>
24+
class _LIBCPP_TEMPLATE_VIS reference_wrapper;
25+
2326
_LIBCPP_END_NAMESPACE_STD
2427

25-
#endif // _LIBCPP___FWD_HASH_H
28+
#endif // _LIBCPP___FWD_FUNCTIONAL_H

libcxx/include/__thread/id.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <__compare/ordering.h>
1414
#include <__config>
15-
#include <__fwd/hash.h>
15+
#include <__fwd/functional.h>
1616
#include <__fwd/ostream.h>
1717
#include <__thread/support.h>
1818

libcxx/include/__thread/support/pthread.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <__chrono/convert_to_timespec.h>
1515
#include <__chrono/duration.h>
1616
#include <__config>
17-
#include <__fwd/hash.h>
1817
#include <ctime>
1918
#include <errno.h>
2019
#include <pthread.h>

libcxx/include/__type_traits/is_reference_wrapper.h

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

1212
#include <__config>
13+
#include <__fwd/functional.h>
1314
#include <__type_traits/integral_constant.h>
1415
#include <__type_traits/remove_cv.h>
1516

@@ -19,9 +20,6 @@
1920

2021
_LIBCPP_BEGIN_NAMESPACE_STD
2122

22-
template <class _Tp>
23-
class _LIBCPP_TEMPLATE_VIS reference_wrapper;
24-
2523
template <class _Tp>
2624
struct __is_reference_wrapper_impl : public false_type {};
2725
template <class _Tp>

libcxx/include/__type_traits/unwrap_ref.h

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

1212
#include <__config>
13+
#include <__fwd/functional.h>
1314
#include <__type_traits/decay.h>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -23,17 +24,11 @@ struct __unwrap_reference {
2324
typedef _LIBCPP_NODEBUG _Tp type;
2425
};
2526

26-
template <class _Tp>
27-
class reference_wrapper;
28-
2927
template <class _Tp>
3028
struct __unwrap_reference<reference_wrapper<_Tp> > {
3129
typedef _LIBCPP_NODEBUG _Tp& type;
3230
};
3331

34-
template <class _Tp>
35-
struct decay;
36-
3732
#if _LIBCPP_STD_VER >= 20
3833
template <class _Tp>
3934
struct unwrap_reference : __unwrap_reference<_Tp> {};

0 commit comments

Comments
 (0)