summaryrefslogtreecommitdiff
path: root/boost/flyweight/flyweight.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/flyweight/flyweight.hpp')
-rw-r--r--boost/flyweight/flyweight.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/boost/flyweight/flyweight.hpp b/boost/flyweight/flyweight.hpp
index fcc867c852..1fb2009fcf 100644
--- a/boost/flyweight/flyweight.hpp
+++ b/boost/flyweight/flyweight.hpp
@@ -47,6 +47,7 @@
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(push)
+#pragma warning(disable:4520) /* multiple default ctors */
#pragma warning(disable:4521) /* multiple copy ctors */
#endif
@@ -436,6 +437,54 @@ BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>(
} /* namespace boost */
+#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
+
+/* hash support */
+
+#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
+namespace std{
+
+template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
+struct hash<boost::flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> >
+{
+ typedef std::size_t result_type;
+ typedef boost::flyweight<
+ T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> argument_type;
+
+ result_type operator()(const argument_type& x)const
+ {
+ typedef typename argument_type::value_type value_type;
+
+ std::hash<const value_type*> h;
+ return h(&x.get());
+ }
+};
+
+} /* namespace std */
+#endif /* !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) */
+
+namespace boost{
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace flyweights{
+#endif
+
+template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
+std::size_t hash_value(const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x)
+{
+ typedef typename flyweight<
+ T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)
+ >::value_type value_type;
+
+ boost::hash<const value_type*> h;
+ return h(&x.get());
+}
+
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace flyweights */
+#endif
+} /* namespace boost */
+#endif /* !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT) */
+
#undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS
#undef BOOST_FLYWEIGHT_TEMPL_ARGS
#undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS