summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/unique_ptr.h
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-11 16:20:24 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-11 16:20:24 +0000
commitf4f18004789eb925cb8ed8e2b282bcac3ddc40eb (patch)
treeaa7302db648ad8852e5444d9a24bd8ad8a8bbbf3 /libstdc++-v3/include/bits/unique_ptr.h
parent1a8fcc169cbceb7238811ffdaae34573c8bed004 (diff)
downloadgcc-f4f18004789eb925cb8ed8e2b282bcac3ddc40eb.tar.gz
2010-06-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (hash<shared_ptr>): Add. * include/bits/shared_ptr_base.h (hash<__shared_ptr>): Likewise. * include/bits/unique_ptr.h (hash<unique_ptr>): Likewise. * testsuite/20_util/shared_ptr/hash/1.cc: New. * testsuite/20_util/unique_ptr/hash/1.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/unique_ptr.h')
-rw-r--r--libstdc++-v3/include/bits/unique_ptr.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index 77d3f607dfd..ac62ff7f304 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -233,7 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// [unique.ptr.runtime]
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 740 - omit specialization for array objects with a compile time length
- template<typename _Tp, typename _Tp_Deleter>
+ template<typename _Tp, typename _Tp_Deleter>
class unique_ptr<_Tp[], _Tp_Deleter>
{
typedef std::tuple<_Tp*, _Tp_Deleter> __tuple_type;
@@ -444,6 +444,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const unique_ptr<_Up, _Up_Deleter>& __y)
{ return !(__x.get() < __y.get()); }
+ /// std::hash specialization for unique_ptr.
+ template<typename _Tp, typename _Tp_Deleter>
+ struct hash<unique_ptr<_Tp, _Tp_Deleter>>
+ : public std::unary_function<unique_ptr<_Tp, _Tp_Deleter>, size_t>
+ {
+ size_t
+ operator()(const unique_ptr<_Tp, _Tp_Deleter>& __u) const
+ {
+ typedef unique_ptr<_Tp, _Tp_Deleter> _UP;
+ return std::hash<typename _UP::pointer>()(__u.get());
+ }
+ };
+
// @} group pointer_abstractions
_GLIBCXX_END_NAMESPACE