Skip to content

Commit b644c5b

Browse files
author
redi
committed
Deprecate nested types in std::hash
* include/bits/c++config (_GLIBCXX17_DEPRECATED): Define. * include/bits/functional_hash.h (__hash_base::result_type) (__hash_base::argument_type): Add _GLIBCXX17_DEPRECATED. * include/std/optional (hash<optional<T>>::result_type) (hash<optional<T>>::argument_type): Add deprecated attribute. (__is_fast_hash<hash<optional<T>>>): Add partial specialization. * include/std/variant (hash<variant<Types...>>::result_type) (hash<variant<Types...>>::argument_type): Add deprecated attribute. (__is_fast_hash<hash<variant<Types...>>>): Add partial specialization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253017 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent f89bc7f commit b644c5b

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

libstdc++-v3/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
2017-09-20 Jonathan Wakely <[email protected]>
22

3+
* include/bits/c++config (_GLIBCXX17_DEPRECATED): Define.
4+
* include/bits/functional_hash.h (__hash_base::result_type)
5+
(__hash_base::argument_type): Add _GLIBCXX17_DEPRECATED.
6+
* include/std/optional (hash<optional<T>>::result_type)
7+
(hash<optional<T>>::argument_type): Add deprecated attribute.
8+
(__is_fast_hash<hash<optional<T>>>): Add partial specialization.
9+
* include/std/variant (hash<variant<Types...>>::result_type)
10+
(hash<variant<Types...>>::argument_type): Add deprecated attribute.
11+
(__is_fast_hash<hash<variant<Types...>>>): Add partial specialization.
12+
313
* libsupc++/exception_ptr.h (copy_exception): Remove deprecated
414
non-standard function.
515

libstdc++-v3/include/bits/c++config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
// Macros for deprecated attributes.
7878
// _GLIBCXX_USE_DEPRECATED
7979
// _GLIBCXX_DEPRECATED
80+
// _GLIBCXX17_DEPRECATED
8081
#ifndef _GLIBCXX_USE_DEPRECATED
8182
# define _GLIBCXX_USE_DEPRECATED 1
8283
#endif
@@ -87,6 +88,12 @@
8788
# define _GLIBCXX_DEPRECATED
8889
#endif
8990

91+
#if defined(__DEPRECATED) && (__cplusplus >= 201703L)
92+
# define _GLIBCXX17_DEPRECATED [[__deprecated__]]
93+
#else
94+
# define _GLIBCXX17_DEPRECATED
95+
#endif
96+
9097
// Macros for ABI tag attributes.
9198
#ifndef _GLIBCXX_ABI_TAG_CXX11
9299
# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))

libstdc++-v3/include/bits/functional_hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
4949
template<typename _Result, typename _Arg>
5050
struct __hash_base
5151
{
52-
typedef _Result result_type;
53-
typedef _Arg argument_type;
52+
typedef _Result result_type _GLIBCXX17_DEPRECATED;
53+
typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
5454
};
5555

5656
/// Primary class template hash.

libstdc++-v3/include/std/optional

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
10281028
: private __poison_hash<remove_const_t<_Tp>>,
10291029
public __optional_hash_call_base<_Tp>
10301030
{
1031-
using result_type = size_t;
1032-
using argument_type = optional<_Tp>;
1031+
using result_type [[__deprecated__]] = size_t;
1032+
using argument_type [[__deprecated__]] = optional<_Tp>;
10331033
};
10341034

1035+
template<typename _Tp>
1036+
struct __is_fast_hash<hash<optional<_Tp>>> : __is_fast_hash<hash<_Tp>>
1037+
{ };
1038+
10351039
/// @}
10361040

10371041
template <typename _Tp> optional(_Tp) -> optional<_Tp>;

libstdc++-v3/include/std/variant

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,15 +1420,15 @@ namespace __variant
14201420
variant<_Types...>, std::index_sequence_for<_Types...>>,
14211421
public __variant_hash_call_base<_Types...>
14221422
{
1423-
using result_type = size_t;
1424-
using argument_type = variant<_Types...>;
1423+
using result_type [[__deprecated__]] = size_t;
1424+
using argument_type [[__deprecated__]] = variant<_Types...>;
14251425
};
14261426

14271427
template<>
14281428
struct hash<monostate>
14291429
{
1430-
using result_type = size_t;
1431-
using argument_type = monostate;
1430+
using result_type [[__deprecated__]] = size_t;
1431+
using argument_type [[__deprecated__]] = monostate;
14321432

14331433
size_t
14341434
operator()(const monostate& __t) const noexcept
@@ -1438,6 +1438,11 @@ namespace __variant
14381438
}
14391439
};
14401440

1441+
template<typename... _Types>
1442+
struct __is_fast_hash<hash<variant<_Types...>>>
1443+
: bool_constant<(__is_fast_hash<_Types>::value && ...)>
1444+
{ };
1445+
14411446
_GLIBCXX_END_NAMESPACE_VERSION
14421447
} // namespace std
14431448

0 commit comments

Comments
 (0)