This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Deprecate nested types in std::hash

C++17 deprecates the argument_type and result_type members of
std::hash specializations. This adds the deprecated attribute to them.

C++17 also deprecates those nested typedefs (and weak result types) in
owner_less, plus, minus, function, reference_wrapper, bind,
{multi,}map::value_compare etc. but we can do that later. I wanted to
make this change now for the new hash<variant<T...>> and
hash<optional<T>> specializations that are new in C++17.

I'm also adding partial specializations for __is_fast_hash for those
new hash specializations, so that unordered containers of
optional<string> or variant<..., string, ...> will cache the 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.

Tested powerpc64le, committed to trunk.

I don't think this is suitable for backporting to gcc-7-branch. The
__is_fast_hash parts would cause incompatibilities between 7.2 and 7.3
for unordered containers.

Attachment: patch.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]