summaryrefslogtreecommitdiff
path: root/boost/flyweight
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:45:20 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:46:37 +0900
commit733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /boost/flyweight
parent08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff)
downloadboost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/flyweight')
-rw-r--r--boost/flyweight/flyweight.hpp49
-rw-r--r--boost/flyweight/flyweight_fwd.hpp42
2 files changed, 90 insertions, 1 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
diff --git a/boost/flyweight/flyweight_fwd.hpp b/boost/flyweight/flyweight_fwd.hpp
index 31b06742ac..81e2aef97d 100644
--- a/boost/flyweight/flyweight_fwd.hpp
+++ b/boost/flyweight/flyweight_fwd.hpp
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2014 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -19,6 +19,11 @@
#include <boost/preprocessor/punctuation/comma.hpp>
#include <iosfwd>
+#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
+#include <boost/functional/hash_fwd.hpp>
+#include <cstddef>
+#endif
+
namespace boost{
namespace flyweights{
@@ -159,6 +164,41 @@ using flyweights::flyweight;
} /* namespace boost */
+#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
+#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
+
+#if !defined(_LIBCPP_VERSION)
+namespace std{
+template <class T> struct hash;
+}
+#else
+/* As discussed in http://lists.boost.org/Archives/boost/2011/02/177218.php */
+#include <functional>
+#endif
+
+namespace std{
+
+template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
+struct hash<boost::flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> >;
+
+} /* 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(_)>
+inline std::size_t hash_value(
+ const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
+
+#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_DECL
#undef BOOST_FLYWEIGHT_TEMPL_ARGS
#undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS