commit 5ecfc92eb86d8e6a90e1168fe6b4b2ab8cd0f8e4 Author: Jonathan Wakely Date: Wed Sep 20 14:33:42 2017 +0100 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>::result_type) (hash>::argument_type): Add deprecated attribute. (__is_fast_hash>>): Add partial specialization. * include/std/variant (hash>::result_type) (hash>::argument_type): Add deprecated attribute. (__is_fast_hash>>): Add partial specialization. diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index d5d1d24ee1a..21e3fbb2741 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -77,6 +77,7 @@ // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED +// _GLIBCXX17_DEPRECATED #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif @@ -87,6 +88,12 @@ # define _GLIBCXX_DEPRECATED #endif +#if defined(__DEPRECATED) && (__cplusplus >= 201703L) +# define _GLIBCXX17_DEPRECATED [[__deprecated__]] +#else +# define _GLIBCXX17_DEPRECATED +#endif + // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h index 38be1724d3f..c0936843ac0 100644 --- a/libstdc++-v3/include/bits/functional_hash.h +++ b/libstdc++-v3/include/bits/functional_hash.h @@ -49,8 +49,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __hash_base { - typedef _Result result_type; - typedef _Arg argument_type; + typedef _Result result_type _GLIBCXX17_DEPRECATED; + typedef _Arg argument_type _GLIBCXX17_DEPRECATED; }; /// Primary class template hash. diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 2df9b5443ef..e017eedbde7 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -1028,10 +1028,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : private __poison_hash>, public __optional_hash_call_base<_Tp> { - using result_type = size_t; - using argument_type = optional<_Tp>; + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = optional<_Tp>; }; + template + struct __is_fast_hash>> : __is_fast_hash> + { }; + /// @} template optional(_Tp) -> optional<_Tp>; diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index ee2571b7857..8f574f63924 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -1420,15 +1420,15 @@ namespace __variant variant<_Types...>, std::index_sequence_for<_Types...>>, public __variant_hash_call_base<_Types...> { - using result_type = size_t; - using argument_type = variant<_Types...>; + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = variant<_Types...>; }; template<> struct hash { - using result_type = size_t; - using argument_type = monostate; + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = monostate; size_t operator()(const monostate& __t) const noexcept @@ -1438,6 +1438,11 @@ namespace __variant } }; + template + struct __is_fast_hash>> + : bool_constant<(__is_fast_hash<_Types>::value && ...)> + { }; + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std