diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 044ee70..3482448 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -15,5 +15,11 @@ boostbook standalone : hash : generate.section.toc.level=2 toc.section.depth=1 toc.max.depth=1 - pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/functional/hash/doc/html + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/container_hash/hash/doc/html ; + +############################################################################### + alias boostdoc : hash ; + explicit boostdoc ; + alias boostrelease ; + explicit boostrelease ; diff --git a/doc/changes.qbk b/doc/changes.qbk index 37dd738..6cf74a8 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -19,8 +19,8 @@ * Use declarations for standard classes, so that the library doesn't need to include all of their headers -* Deprecated the `` headers. Now a single header, - <[headerref boost/functional/hash.hpp]> is used. +* Deprecated the `` headers. Now a single header, + <[headerref boost/container_hash/hash.hpp]> is used. * Add support for the `BOOST_HASH_NO_EXTENSIONS` macro, which disables the extensions to TR1. @@ -71,10 +71,10 @@ * Changed the warnings in the deprecated headers from 1.34.0 to errors. These will be removed in a future version of Boost. -* Moved detail headers out of `boost/functional/detail`, since they are part of - functional/hash, not functional. `boost/functional/detail/container_fwd.hpp` +* Moved detail headers out of `boost/container_hash/detail`, since they are part of + container_hash/hash, not container_hash. `boost/container_hash/detail/container_fwd.hpp` has been moved to `boost/detail/container_fwd.hpp` as it's used outside of - this library, the others have been moved to `boost/functional/hash/detail`. + this library, the others have been moved to `boost/container_hash/hash/detail`. [h2 Boost 1.39.0] @@ -132,7 +132,7 @@ * [@http://svn.boost.org/trac/boost/ticket/6806 Ticket 6806]: Support `std::array` and `std::tuple` when available. * Add deprecation warning to the long deprecated - `boost/functional/detail/container_fwd.hpp`. + `boost/container_hash/detail/container_fwd.hpp`. [h2 Boost 1.51.0] @@ -177,7 +177,7 @@ [h2 Boost 1.58.0] * Fixed strict aliasing violation - ([@https://github.com/boostorg/functional/pull/3 GitHub #3]). + ([@https://github.com/boostorg/container_hash/pull/3 GitHub #3]). [h2 Boost 1.63.0] diff --git a/doc/disable.qbk b/doc/disable.qbk index 27dec6b..5373b42 100644 --- a/doc/disable.qbk +++ b/doc/disable.qbk @@ -10,7 +10,7 @@ to turn them of in order to check that your code will work with other implementations of TR1. To do this define the macro `BOOST_HASH_NO_EXTENSIONS`. When this macro is defined, only the specialisations detailed in TR1 will be declared. But, if you later undefine the macro and include -<[headerref boost/functional/hash.hpp]> then the non-specialised form will be defined +<[headerref boost/container_hash/hash.hpp]> then the non-specialised form will be defined - activating the extensions. It is strongly recommended that you never undefine the macro - and only define diff --git a/doc/hash.qbk b/doc/hash.qbk index cdb72d4..3bcc80e 100644 --- a/doc/hash.qbk +++ b/doc/hash.qbk @@ -1,4 +1,4 @@ -[library Boost.Functional/Hash +[library Boost.ContainerHash [quickbook 1.5] [authors [James, Daniel]] [copyright 2005 2006 2007 2008 Daniel James] @@ -6,7 +6,7 @@ defined types] [category higher-order] [id hash] - [dirname functional/hash] + [dirname container_hash] [license Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/doc/portability.qbk b/doc/portability.qbk index a65bc19..7db3e56 100644 --- a/doc/portability.qbk +++ b/doc/portability.qbk @@ -88,6 +88,6 @@ boost namespace: } Full code for this example is at -[@boost:/libs/functional/hash/examples/portable.cpp /libs/functional/hash/examples/portable.cpp]. +[@boost:/libs/container_hash/hash/examples/portable.cpp /libs/container_hash/hash/examples/portable.cpp]. [endsect] diff --git a/doc/ref.xml b/doc/ref.xml index f5fd185..1c8bca9 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -13,7 +13,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Library Extension Technical Report Issues List (page 63). -
+
Defines boost::hash, and helper functions. @@ -57,7 +57,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Forward declared in - <boost/functional/hash_fwd.hpp> + <boost/container_hash/hash_fwd.hpp> This hash function is not intended for general use, and isn't @@ -542,7 +542,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) This is an extension to TR1 Forward declared in - <boost/functional/hash_fwd.hpp> + <boost/container_hash/hash_fwd.hpp> This hash function is not intended for general use, and isn't @@ -615,7 +615,7 @@ for(; first != last; ++first) This is an extension to TR1 Forward declared in - <boost/functional/hash_fwd.hpp> + <boost/container_hash/hash_fwd.hpp> This hash function is not intended for general use, and isn't diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index 59067a7..2c0d1f3 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -27,7 +27,7 @@ associative containers and you wish to use To use [classref boost::hash] directly, create an instance and call it as a function: - #include <``[headerref boost/functional/hash.hpp]``> + #include <``[headerref boost/container_hash/hash.hpp]``> int main() { @@ -110,9 +110,9 @@ And you can now use [classref boost::hash] with book: assert(books.find(dandelion) == books.end()); The full example can be found in: -[@boost:/libs/functional/hash/examples/books.hpp /libs/functional/hash/examples/books.hpp] +[@boost:/libs/container_hash/hash/examples/books.hpp /libs/container_hash/hash/examples/books.hpp] and -[@boost:/libs/functional/hash/examples/books.cpp /libs/functional/hash/examples/books.cpp]. +[@boost:/libs/container_hash/hash/examples/books.cpp /libs/container_hash/hash/examples/books.cpp]. [tip When writing a hash function, first look at how the equality function works. @@ -170,7 +170,7 @@ of point, it can be repeatedly called for any number of elements. It calls [funcref boost::hash_value hash_value] on the supplied element, and combines it with the seed. Full code for this example is at -[@boost:/libs/functional/hash/examples/point.cpp /libs/functional/hash/examples/point.cpp]. +[@boost:/libs/container_hash/hash/examples/point.cpp /libs/container_hash/hash/examples/point.cpp]. [note When using [funcref boost::hash_combine] the order of the @@ -200,13 +200,13 @@ To calculate the hash of an iterator range you can use [funcref boost::hash_rang Note that when writing template classes, you might not want to include the main hash header as it's quite an expensive include that brings in a lot of other -headers, so instead you can include the `` +headers, so instead you can include the `` header which forward declares [classref boost::hash], [funcref boost::hash_range] and [funcref boost::hash_combine]. You'll need to include the main header before instantiating [classref boost::hash]. When using a container that uses [classref boost::hash] it should do that for you, so your type will work fine with the boost hash containers. There's an example of this -in [@boost:/libs/functional/hash/examples/template.hpp template.hpp] and -[@boost:/libs/functional/hash/examples/template.cpp template.cpp]. +in [@boost:/libs/container_hash/hash/examples/template.hpp template.hpp] and +[@boost:/libs/container_hash/hash/examples/template.cpp template.cpp]. [endsect] diff --git a/examples/books.cpp b/examples/books.cpp index 40feae3..3dfa547 100644 --- a/examples/books.cpp +++ b/examples/books.cpp @@ -4,7 +4,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "./books.hpp" -#include +#include #include // If std::unordered_set was available: diff --git a/examples/point.cpp b/examples/point.cpp index f3d30e1..3f5e8be 100644 --- a/examples/point.cpp +++ b/examples/point.cpp @@ -8,7 +8,7 @@ #undef NDEBUG #endif -#include +#include #include // This example illustrates how to use boost::hash_combine to generate a hash diff --git a/examples/portable.cpp b/examples/portable.cpp index 511133e..e0ea96a 100644 --- a/examples/portable.cpp +++ b/examples/portable.cpp @@ -8,7 +8,7 @@ #undef NDEBUG #endif -#include +#include #include // This example illustrates how to customise boost::hash portably, so that diff --git a/examples/template.hpp b/examples/template.hpp index b630704..0a2fe13 100644 --- a/examples/template.hpp +++ b/examples/template.hpp @@ -6,7 +6,7 @@ // This is an example of how to write a hash function for a template // class. -#include +#include template class my_pair diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp new file mode 100644 index 0000000..4a06833 --- /dev/null +++ b/include/boost/container_hash/hash.hpp @@ -0,0 +1,7 @@ + +// Copyright 2005-2009 Daniel James. +// 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) + +#include + diff --git a/include/boost/functional/hash/detail/float_functions.hpp b/include/boost/container_hash/hash/detail/float_functions.hpp similarity index 100% rename from include/boost/functional/hash/detail/float_functions.hpp rename to include/boost/container_hash/hash/detail/float_functions.hpp diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/container_hash/hash/detail/hash_float.hpp similarity index 98% rename from include/boost/functional/hash/detail/hash_float.hpp rename to include/boost/container_hash/hash/detail/hash_float.hpp index 1816c57..d0f7f55 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/container_hash/hash/detail/hash_float.hpp @@ -11,9 +11,9 @@ #pragma once #endif -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/include/boost/functional/hash/detail/limits.hpp b/include/boost/container_hash/hash/detail/limits.hpp similarity index 100% rename from include/boost/functional/hash/detail/limits.hpp rename to include/boost/container_hash/hash/detail/limits.hpp diff --git a/include/boost/container_hash/hash/extensions.hpp b/include/boost/container_hash/hash/extensions.hpp new file mode 100644 index 0000000..d8e34db --- /dev/null +++ b/include/boost/container_hash/hash/extensions.hpp @@ -0,0 +1,363 @@ + +// Copyright 2005-2009 Daniel James. +// 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) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. + +// This implements the extensions to the standard. +// It's undocumented, so you shouldn't use it.... + +#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) +#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include +#include +#include +#include + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_MEMORY) +# include +#endif + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#include +#endif + +namespace boost +{ + template + std::size_t hash_value(std::pair const&); + template + std::size_t hash_value(std::vector const&); + template + std::size_t hash_value(std::list const& v); + template + std::size_t hash_value(std::deque const& v); + template + std::size_t hash_value(std::set const& v); + template + std::size_t hash_value(std::multiset const& v); + template + std::size_t hash_value(std::map const& v); + template + std::size_t hash_value(std::multimap const& v); + + template + std::size_t hash_value(std::complex const&); + + template + std::size_t hash_value(std::pair const& v) + { + std::size_t seed = 0; + boost::hash_combine(seed, v.first); + boost::hash_combine(seed, v.second); + return seed; + } + + template + std::size_t hash_value(std::vector const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::list const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::deque const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::set const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::multiset const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::map const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::multimap const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::complex const& v) + { + boost::hash hasher; + std::size_t seed = hasher(v.imag()); + seed ^= hasher(v.real()) + (seed<<6) + (seed>>2); + return seed; + } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) + template + std::size_t hash_value(std::array const& v) + { + return boost::hash_range(v.begin(), v.end()); + } +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) + namespace hash_detail { + template + inline typename boost::enable_if_c<(I == std::tuple_size::value), + void>::type + hash_combine_tuple(std::size_t&, T const&) + { + } + + template + inline typename boost::enable_if_c<(I < std::tuple_size::value), + void>::type + hash_combine_tuple(std::size_t& seed, T const& v) + { + boost::hash_combine(seed, std::get(v)); + boost::hash_detail::hash_combine_tuple(seed, v); + } + + template + inline std::size_t hash_tuple(T const& v) + { + std::size_t seed = 0; + boost::hash_detail::hash_combine_tuple<0>(seed, v); + return seed; + } + } + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } +#else + + inline std::size_t hash_value(std::tuple<> const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + +#endif + +#endif + +#if !defined(BOOST_NO_CXX11_SMART_PTR) + template + inline std::size_t hash_value(std::shared_ptr const& x) { + return boost::hash_value(x.get()); + } + + template + inline std::size_t hash_value(std::unique_ptr const& x) { + return boost::hash_value(x.get()); + } +#endif + + // + // call_hash_impl + // + + // On compilers without function template ordering, this deals with arrays. + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + namespace hash_detail + { + template + struct call_hash_impl + { + template + struct inner + { + static std::size_t call(T const& v) + { + using namespace boost; + return hash_value(v); + } + }; + }; + + template <> + struct call_hash_impl + { + template + struct inner + { + static std::size_t call(Array const& v) + { + const int size = sizeof(v) / sizeof(*v); + return boost::hash_range(v, v + size); + } + }; + }; + + template + struct call_hash + : public call_hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + } +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + // + // boost::hash + // + + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + template struct hash + : boost::hash_detail::hash_base + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + +#if BOOST_WORKAROUND(__DMC__, <= 0x848) + template struct hash + : boost::hash_detail::hash_base + { + std::size_t operator()(const T* val) const + { + return boost::hash_range(val, val+n); + } + }; +#endif + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // On compilers without partial specialization, boost::hash + // has already been declared to deal with pointers, so just + // need to supply the non-pointer version of hash_impl. + + namespace hash_detail + { + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner + : boost::hash_detail::hash_base + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + }; + } +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +} + +#endif diff --git a/include/boost/container_hash/hash/hash.hpp b/include/boost/container_hash/hash/hash.hpp new file mode 100644 index 0000000..21296f3 --- /dev/null +++ b/include/boost/container_hash/hash/hash.hpp @@ -0,0 +1,595 @@ + +// Copyright 2005-2014 Daniel James. +// 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) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. +// +// This also contains public domain code from MurmurHash. From the +// MurmurHash header: + +// MurmurHash3 was written by Austin Appleby, and is placed in the public +// domain. The author hereby disclaims copyright to this source code. + +#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP) +#define BOOST_FUNCTIONAL_HASH_HASH_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +#include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) +#include +#endif + +#if defined(BOOST_MSVC) +#pragma warning(push) + +#if BOOST_MSVC >= 1400 +#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values + // are always of range '0' to '4294967295'. + // Loop executes infinitely. +#endif + +#endif + +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#define BOOST_HASH_CHAR_TRAITS string_char_traits +#else +#define BOOST_HASH_CHAR_TRAITS char_traits +#endif + +#if defined(_MSC_VER) +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r) +#else +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r)) +#endif + +namespace boost +{ + namespace hash_detail + { +#if defined(_HAS_AUTO_PTR_ETC) && !_HAS_AUTO_PTR_ETC + template + struct hash_base + { + typedef T argument_type; + typedef std::size_t result_type; + }; +#else + template + struct hash_base : std::unary_function {}; +#endif + + struct enable_hash_value { typedef std::size_t type; }; + + template struct basic_numbers {}; + template struct long_numbers; + template struct ulong_numbers; + template struct float_numbers {}; + + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR16_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR32_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + + // long_numbers is defined like this to allow for separate + // specialization for long_long and int128_type, in case + // they conflict. + template struct long_numbers2 {}; + template struct ulong_numbers2 {}; + template struct long_numbers : long_numbers2 {}; + template struct ulong_numbers : ulong_numbers2 {}; + +#if !defined(BOOST_NO_LONG_LONG) + template <> struct long_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if defined(BOOST_HAS_INT128) + template <> struct long_numbers2 : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers2 : + boost::hash_detail::enable_hash_value {}; +#endif + + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + } + + template + typename boost::hash_detail::basic_numbers::type hash_value(T); + template + typename boost::hash_detail::long_numbers::type hash_value(T); + template + typename boost::hash_detail::ulong_numbers::type hash_value(T); + + template + typename boost::enable_if, std::size_t>::type + hash_value(T); + +#if !BOOST_WORKAROUND(__DMC__, <= 0x848) + template std::size_t hash_value(T* const&); +#else + template std::size_t hash_value(T*); +#endif + +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + template< class T, unsigned N > + std::size_t hash_value(const T (&x)[N]); + + template< class T, unsigned N > + std::size_t hash_value(T (&x)[N]); +#endif + + template + std::size_t hash_value( + std::basic_string, A> const&); + + template + typename boost::hash_detail::float_numbers::type hash_value(T); + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + std::size_t hash_value(std::type_index); +#endif + + // Implementation + + namespace hash_detail + { + template + inline std::size_t hash_value_signed(T val) + { + const unsigned int size_t_bits = std::numeric_limits::digits; + // ceiling(std::numeric_limits::digits / size_t_bits) - 1 + const int length = (std::numeric_limits::digits - 1) + / static_cast(size_t_bits); + + std::size_t seed = 0; + T positive = val < 0 ? -1 - val : val; + + // Hopefully, this loop can be unrolled. + for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) + { + seed ^= (std::size_t) (positive >> i) + (seed<<6) + (seed>>2); + } + seed ^= (std::size_t) val + (seed<<6) + (seed>>2); + + return seed; + } + + template + inline std::size_t hash_value_unsigned(T val) + { + const unsigned int size_t_bits = std::numeric_limits::digits; + // ceiling(std::numeric_limits::digits / size_t_bits) - 1 + const int length = (std::numeric_limits::digits - 1) + / static_cast(size_t_bits); + + std::size_t seed = 0; + + // Hopefully, this loop can be unrolled. + for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) + { + seed ^= (std::size_t) (val >> i) + (seed<<6) + (seed>>2); + } + seed ^= (std::size_t) val + (seed<<6) + (seed>>2); + + return seed; + } + + template + inline void hash_combine_impl(SizeT& seed, SizeT value) + { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + inline void hash_combine_impl(boost::uint32_t& h1, + boost::uint32_t k1) + { + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + k1 *= c1; + k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = BOOST_FUNCTIONAL_HASH_ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + +// Don't define 64-bit hash combine on platforms without 64 bit integers, +// and also not for 32-bit gcc as it warns about the 64-bit constant. +#if !defined(BOOST_NO_INT64_T) && \ + !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) + + inline void hash_combine_impl(boost::uint64_t& h, + boost::uint64_t k) + { + const boost::uint64_t m = UINT64_C(0xc6a4a7935bd1e995); + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + + // Completely arbitrary number, to prevent 0's + // from hashing to 0. + h += 0xe6546b64; + } + +#endif // BOOST_NO_INT64_T + } + + template + typename boost::hash_detail::basic_numbers::type hash_value(T v) + { + return static_cast(v); + } + + template + typename boost::hash_detail::long_numbers::type hash_value(T v) + { + return hash_detail::hash_value_signed(v); + } + + template + typename boost::hash_detail::ulong_numbers::type hash_value(T v) + { + return hash_detail::hash_value_unsigned(v); + } + + template + typename boost::enable_if, std::size_t>::type + hash_value(T v) + { + return static_cast(v); + } + + // Implementation by Alberto Barbati and Dave Harris. +#if !BOOST_WORKAROUND(__DMC__, <= 0x848) + template std::size_t hash_value(T* const& v) +#else + template std::size_t hash_value(T* v) +#endif + { +#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 + // for some reason ptrdiff_t on OpenVMS compiler with + // 64 bit is not 64 bit !!! + std::size_t x = static_cast( + reinterpret_cast(v)); +#else + std::size_t x = static_cast( + reinterpret_cast(v)); +#endif + return x + (x >> 3); + } + +#if defined(BOOST_MSVC) +#pragma warning(push) +#if BOOST_MSVC <= 1400 +#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to + // 'unsigned int', possible loss of data + // A misguided attempt to detect 64-bit + // incompatability. +#endif +#endif + + template + inline void hash_combine(std::size_t& seed, T const& v) + { + boost::hash hasher; + return boost::hash_detail::hash_combine_impl(seed, hasher(v)); + } + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + + template + inline std::size_t hash_range(It first, It last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + + return seed; + } + + template + inline void hash_range(std::size_t& seed, It first, It last) + { + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + } + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + inline std::size_t hash_range(T* first, T* last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + boost::hash hasher; + seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + return seed; + } + + template + inline void hash_range(std::size_t& seed, T* first, T* last) + { + for(; first != last; ++first) + { + boost::hash hasher; + seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + } +#endif + +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + template< class T, unsigned N > + inline std::size_t hash_value(const T (&x)[N]) + { + return hash_range(x, x + N); + } + + template< class T, unsigned N > + inline std::size_t hash_value(T (&x)[N]) + { + return hash_range(x, x + N); + } +#endif + + template + inline std::size_t hash_value( + std::basic_string, A> const& v) + { + return hash_range(v.begin(), v.end()); + } + + template + typename boost::hash_detail::float_numbers::type hash_value(T v) + { + return boost::hash_detail::float_hash_value(v); + } + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + inline std::size_t hash_value(std::type_index v) + { + return v.hash_code(); + } +#endif + + // + // boost::hash + // + + // Define the specializations required by the standard. The general purpose + // boost::hash is defined later in extensions.hpp if + // BOOST_HASH_NO_EXTENSIONS is not defined. + + // BOOST_HASH_SPECIALIZE - define a specialization for a type which is + // passed by copy. + // + // BOOST_HASH_SPECIALIZE_REF - define a specialization for a type which is + // passed by const reference. + // + // These are undefined later. + +#define BOOST_HASH_SPECIALIZE(type) \ + template <> struct hash \ + : public boost::hash_detail::hash_base \ + { \ + std::size_t operator()(type v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + +#define BOOST_HASH_SPECIALIZE_REF(type) \ + template <> struct hash \ + : public boost::hash_detail::hash_base \ + { \ + std::size_t operator()(type const& v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + + BOOST_HASH_SPECIALIZE(bool) + BOOST_HASH_SPECIALIZE(char) + BOOST_HASH_SPECIALIZE(signed char) + BOOST_HASH_SPECIALIZE(unsigned char) +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_HASH_SPECIALIZE(wchar_t) +#endif +#if !defined(BOOST_NO_CXX11_CHAR16_T) + BOOST_HASH_SPECIALIZE(char16_t) +#endif +#if !defined(BOOST_NO_CXX11_CHAR32_T) + BOOST_HASH_SPECIALIZE(char32_t) +#endif + BOOST_HASH_SPECIALIZE(short) + BOOST_HASH_SPECIALIZE(unsigned short) + BOOST_HASH_SPECIALIZE(int) + BOOST_HASH_SPECIALIZE(unsigned int) + BOOST_HASH_SPECIALIZE(long) + BOOST_HASH_SPECIALIZE(unsigned long) + + BOOST_HASH_SPECIALIZE(float) + BOOST_HASH_SPECIALIZE(double) + BOOST_HASH_SPECIALIZE(long double) + + BOOST_HASH_SPECIALIZE_REF(std::string) +#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_HASH_SPECIALIZE_REF(std::wstring) +#endif +#if !defined(BOOST_NO_CXX11_CHAR16_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string) +#endif +#if !defined(BOOST_NO_CXX11_CHAR32_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string) +#endif + +#if !defined(BOOST_NO_LONG_LONG) + BOOST_HASH_SPECIALIZE(boost::long_long_type) + BOOST_HASH_SPECIALIZE(boost::ulong_long_type) +#endif + +#if defined(BOOST_HAS_INT128) + BOOST_HASH_SPECIALIZE(boost::int128_type) + BOOST_HASH_SPECIALIZE(boost::uint128_type) +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + BOOST_HASH_SPECIALIZE(std::type_index) +#endif + +#undef BOOST_HASH_SPECIALIZE +#undef BOOST_HASH_SPECIALIZE_REF + +// Specializing boost::hash for pointers. + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + template + struct hash + : public boost::hash_detail::hash_base + { + std::size_t operator()(T* v) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) + return boost::hash_value(v); +#else + std::size_t x = static_cast( + reinterpret_cast(v)); + + return x + (x >> 3); +#endif + } + }; + +#else + + // For compilers without partial specialization, we define a + // boost::hash for all remaining types. But hash_impl is only defined + // for pointers in 'extensions.hpp' - so when BOOST_HASH_NO_EXTENSIONS + // is defined there will still be a compile error for types not supported + // in the standard. + + namespace hash_detail + { + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner + : public boost::hash_detail::hash_base + { + std::size_t operator()(T val) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) + return boost::hash_value(val); +#else + std::size_t x = static_cast( + reinterpret_cast(val)); + + return x + (x >> 3); +#endif + } + }; + }; + } + + template struct hash + : public boost::hash_detail::hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + +#endif +} + +#undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_FUNCTIONAL_HASH_ROTL32 + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP + +// Include this outside of the include guards in case the file is included +// twice - once with BOOST_HASH_NO_EXTENSIONS defined, and then with it +// undefined. + +#if !defined(BOOST_HASH_NO_EXTENSIONS) \ + && !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) +#include +#endif diff --git a/include/boost/container_hash/hash/hash_fwd.hpp b/include/boost/container_hash/hash/hash_fwd.hpp new file mode 100644 index 0000000..a87c182 --- /dev/null +++ b/include/boost/container_hash/hash/hash_fwd.hpp @@ -0,0 +1,36 @@ + +// Copyright 2005-2009 Daniel James. +// 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) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. + +#if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) +#define BOOST_FUNCTIONAL_HASH_FWD_HPP + +#include +#include + +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + + +namespace boost +{ + template struct hash; + + template void hash_combine(std::size_t& seed, T const& v); + + template std::size_t hash_range(It, It); + template void hash_range(std::size_t&, It, It); + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template inline std::size_t hash_range(T*, T*); + template inline void hash_range(std::size_t&, T*, T*); +#endif +} + +#endif diff --git a/include/boost/container_hash/hash_fwd.hpp b/include/boost/container_hash/hash_fwd.hpp new file mode 100644 index 0000000..5ff4801 --- /dev/null +++ b/include/boost/container_hash/hash_fwd.hpp @@ -0,0 +1,11 @@ + +// Copyright 2005-2009 Daniel James. +// 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) + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include diff --git a/include/boost/functional/hash.hpp b/include/boost/functional/hash.hpp index 44983f1..6122b35 100644 --- a/include/boost/functional/hash.hpp +++ b/include/boost/functional/hash.hpp @@ -3,5 +3,4 @@ // 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) -#include - +#include diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index cb3c856..bd436fb 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -1,318 +1,6 @@ -// Copyright 2005-2009 Daniel James. +// Copyright 2017 Daniel James. // 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) -// Based on Peter Dimov's proposal -// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf -// issue 6.18. - -// This implements the extensions to the standard. -// It's undocumented, so you shouldn't use it.... - -#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) -#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP - -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include -#include -#include -#include -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_ARRAY) -# include -#endif - -#if !defined(BOOST_NO_CXX11_HDR_TUPLE) -# include -#endif - -#if !defined(BOOST_NO_CXX11_HDR_MEMORY) -# include -#endif - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) -#include -#endif - -namespace boost -{ - template - std::size_t hash_value(std::pair const&); - template - std::size_t hash_value(std::vector const&); - template - std::size_t hash_value(std::list const& v); - template - std::size_t hash_value(std::deque const& v); - template - std::size_t hash_value(std::set const& v); - template - std::size_t hash_value(std::multiset const& v); - template - std::size_t hash_value(std::map const& v); - template - std::size_t hash_value(std::multimap const& v); - - template - std::size_t hash_value(std::complex const&); - - template - std::size_t hash_value(std::pair const& v) - { - std::size_t seed = 0; - boost::hash_combine(seed, v.first); - boost::hash_combine(seed, v.second); - return seed; - } - - template - std::size_t hash_value(std::vector const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::list const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::deque const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::set const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::multiset const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::map const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::multimap const& v) - { - return boost::hash_range(v.begin(), v.end()); - } - - template - std::size_t hash_value(std::complex const& v) - { - boost::hash hasher; - std::size_t seed = hasher(v.imag()); - seed ^= hasher(v.real()) + (seed<<6) + (seed>>2); - return seed; - } - -#if !defined(BOOST_NO_CXX11_HDR_ARRAY) - template - std::size_t hash_value(std::array const& v) - { - return boost::hash_range(v.begin(), v.end()); - } -#endif - -#if !defined(BOOST_NO_CXX11_HDR_TUPLE) - namespace hash_detail { - template - inline typename boost::enable_if_c<(I == std::tuple_size::value), - void>::type - hash_combine_tuple(std::size_t&, T const&) - { - } - - template - inline typename boost::enable_if_c<(I < std::tuple_size::value), - void>::type - hash_combine_tuple(std::size_t& seed, T const& v) - { - boost::hash_combine(seed, std::get(v)); - boost::hash_detail::hash_combine_tuple(seed, v); - } - - template - inline std::size_t hash_tuple(T const& v) - { - std::size_t seed = 0; - boost::hash_detail::hash_combine_tuple<0>(seed, v); - return seed; - } - } - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - inline std::size_t hash_value(std::tuple const& v) - { - return boost::hash_detail::hash_tuple(v); - } -#else - - inline std::size_t hash_value(std::tuple<> const& v) - { - return boost::hash_detail::hash_tuple(v); - } - -# define BOOST_HASH_TUPLE_F(z, n, _) \ - template< \ - BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ - > \ - inline std::size_t hash_value(std::tuple< \ - BOOST_PP_ENUM_PARAMS_Z(z, n, A) \ - > const& v) \ - { \ - return boost::hash_detail::hash_tuple(v); \ - } - - BOOST_PP_REPEAT_FROM_TO(1, 11, BOOST_HASH_TUPLE_F, _) -# undef BOOST_HASH_TUPLE_F -#endif - -#endif - -#if !defined(BOOST_NO_CXX11_SMART_PTR) - template - inline std::size_t hash_value(std::shared_ptr const& x) { - return boost::hash_value(x.get()); - } - - template - inline std::size_t hash_value(std::unique_ptr const& x) { - return boost::hash_value(x.get()); - } -#endif - - // - // call_hash_impl - // - - // On compilers without function template ordering, this deals with arrays. - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - namespace hash_detail - { - template - struct call_hash_impl - { - template - struct inner - { - static std::size_t call(T const& v) - { - using namespace boost; - return hash_value(v); - } - }; - }; - - template <> - struct call_hash_impl - { - template - struct inner - { - static std::size_t call(Array const& v) - { - const int size = sizeof(v) / sizeof(*v); - return boost::hash_range(v, v + size); - } - }; - }; - - template - struct call_hash - : public call_hash_impl::value> - ::BOOST_NESTED_TEMPLATE inner - { - }; - } -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - // - // boost::hash - // - - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - template struct hash - : boost::hash_detail::hash_base - { -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - std::size_t operator()(T const& val) const - { - return hash_value(val); - } -#else - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } -#endif - }; - -#if BOOST_WORKAROUND(__DMC__, <= 0x848) - template struct hash - : boost::hash_detail::hash_base - { - std::size_t operator()(const T* val) const - { - return boost::hash_range(val, val+n); - } - }; -#endif - -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // On compilers without partial specialization, boost::hash - // has already been declared to deal with pointers, so just - // need to supply the non-pointer version of hash_impl. - - namespace hash_detail - { - template - struct hash_impl; - - template <> - struct hash_impl - { - template - struct inner - : boost::hash_detail::hash_base - { -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - std::size_t operator()(T const& val) const - { - return hash_value(val); - } -#else - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } -#endif - }; - }; - } -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -} - -#endif +#include diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index b461f5f..6122b35 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -1,595 +1,6 @@ -// Copyright 2005-2014 Daniel James. +// Copyright 2005-2009 Daniel James. // 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) -// Based on Peter Dimov's proposal -// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf -// issue 6.18. -// -// This also contains public domain code from MurmurHash. From the -// MurmurHash header: - -// MurmurHash3 was written by Austin Appleby, and is placed in the public -// domain. The author hereby disclaims copyright to this source code. - -#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP) -#define BOOST_FUNCTIONAL_HASH_HASH_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) -#include -#endif - -#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) -#include -#endif - -#if defined(BOOST_MSVC) -#pragma warning(push) - -#if BOOST_MSVC >= 1400 -#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values - // are always of range '0' to '4294967295'. - // Loop executes infinitely. -#endif - -#endif - -#if BOOST_WORKAROUND(__GNUC__, < 3) \ - && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) -#define BOOST_HASH_CHAR_TRAITS string_char_traits -#else -#define BOOST_HASH_CHAR_TRAITS char_traits -#endif - -#if defined(_MSC_VER) -# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r) -#else -# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r)) -#endif - -namespace boost -{ - namespace hash_detail - { -#if defined(_HAS_AUTO_PTR_ETC) && !_HAS_AUTO_PTR_ETC - template - struct hash_base - { - typedef T argument_type; - typedef std::size_t result_type; - }; -#else - template - struct hash_base : std::unary_function {}; -#endif - - struct enable_hash_value { typedef std::size_t type; }; - - template struct basic_numbers {}; - template struct long_numbers; - template struct ulong_numbers; - template struct float_numbers {}; - - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; -#endif - -#if !defined(BOOST_NO_CXX11_CHAR16_T) - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; -#endif - -#if !defined(BOOST_NO_CXX11_CHAR32_T) - template <> struct basic_numbers : - boost::hash_detail::enable_hash_value {}; -#endif - - // long_numbers is defined like this to allow for separate - // specialization for long_long and int128_type, in case - // they conflict. - template struct long_numbers2 {}; - template struct ulong_numbers2 {}; - template struct long_numbers : long_numbers2 {}; - template struct ulong_numbers : ulong_numbers2 {}; - -#if !defined(BOOST_NO_LONG_LONG) - template <> struct long_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct ulong_numbers : - boost::hash_detail::enable_hash_value {}; -#endif - -#if defined(BOOST_HAS_INT128) - template <> struct long_numbers2 : - boost::hash_detail::enable_hash_value {}; - template <> struct ulong_numbers2 : - boost::hash_detail::enable_hash_value {}; -#endif - - template <> struct float_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct float_numbers : - boost::hash_detail::enable_hash_value {}; - template <> struct float_numbers : - boost::hash_detail::enable_hash_value {}; - } - - template - typename boost::hash_detail::basic_numbers::type hash_value(T); - template - typename boost::hash_detail::long_numbers::type hash_value(T); - template - typename boost::hash_detail::ulong_numbers::type hash_value(T); - - template - typename boost::enable_if, std::size_t>::type - hash_value(T); - -#if !BOOST_WORKAROUND(__DMC__, <= 0x848) - template std::size_t hash_value(T* const&); -#else - template std::size_t hash_value(T*); -#endif - -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - template< class T, unsigned N > - std::size_t hash_value(const T (&x)[N]); - - template< class T, unsigned N > - std::size_t hash_value(T (&x)[N]); -#endif - - template - std::size_t hash_value( - std::basic_string, A> const&); - - template - typename boost::hash_detail::float_numbers::type hash_value(T); - -#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) - std::size_t hash_value(std::type_index); -#endif - - // Implementation - - namespace hash_detail - { - template - inline std::size_t hash_value_signed(T val) - { - const unsigned int size_t_bits = std::numeric_limits::digits; - // ceiling(std::numeric_limits::digits / size_t_bits) - 1 - const int length = (std::numeric_limits::digits - 1) - / static_cast(size_t_bits); - - std::size_t seed = 0; - T positive = val < 0 ? -1 - val : val; - - // Hopefully, this loop can be unrolled. - for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) - { - seed ^= (std::size_t) (positive >> i) + (seed<<6) + (seed>>2); - } - seed ^= (std::size_t) val + (seed<<6) + (seed>>2); - - return seed; - } - - template - inline std::size_t hash_value_unsigned(T val) - { - const unsigned int size_t_bits = std::numeric_limits::digits; - // ceiling(std::numeric_limits::digits / size_t_bits) - 1 - const int length = (std::numeric_limits::digits - 1) - / static_cast(size_t_bits); - - std::size_t seed = 0; - - // Hopefully, this loop can be unrolled. - for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) - { - seed ^= (std::size_t) (val >> i) + (seed<<6) + (seed>>2); - } - seed ^= (std::size_t) val + (seed<<6) + (seed>>2); - - return seed; - } - - template - inline void hash_combine_impl(SizeT& seed, SizeT value) - { - seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - - inline void hash_combine_impl(boost::uint32_t& h1, - boost::uint32_t k1) - { - const uint32_t c1 = 0xcc9e2d51; - const uint32_t c2 = 0x1b873593; - - k1 *= c1; - k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); - k1 *= c2; - - h1 ^= k1; - h1 = BOOST_FUNCTIONAL_HASH_ROTL32(h1,13); - h1 = h1*5+0xe6546b64; - } - - -// Don't define 64-bit hash combine on platforms without 64 bit integers, -// and also not for 32-bit gcc as it warns about the 64-bit constant. -#if !defined(BOOST_NO_INT64_T) && \ - !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) - - inline void hash_combine_impl(boost::uint64_t& h, - boost::uint64_t k) - { - const boost::uint64_t m = UINT64_C(0xc6a4a7935bd1e995); - const int r = 47; - - k *= m; - k ^= k >> r; - k *= m; - - h ^= k; - h *= m; - - // Completely arbitrary number, to prevent 0's - // from hashing to 0. - h += 0xe6546b64; - } - -#endif // BOOST_NO_INT64_T - } - - template - typename boost::hash_detail::basic_numbers::type hash_value(T v) - { - return static_cast(v); - } - - template - typename boost::hash_detail::long_numbers::type hash_value(T v) - { - return hash_detail::hash_value_signed(v); - } - - template - typename boost::hash_detail::ulong_numbers::type hash_value(T v) - { - return hash_detail::hash_value_unsigned(v); - } - - template - typename boost::enable_if, std::size_t>::type - hash_value(T v) - { - return static_cast(v); - } - - // Implementation by Alberto Barbati and Dave Harris. -#if !BOOST_WORKAROUND(__DMC__, <= 0x848) - template std::size_t hash_value(T* const& v) -#else - template std::size_t hash_value(T* v) -#endif - { -#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 - // for some reason ptrdiff_t on OpenVMS compiler with - // 64 bit is not 64 bit !!! - std::size_t x = static_cast( - reinterpret_cast(v)); -#else - std::size_t x = static_cast( - reinterpret_cast(v)); -#endif - return x + (x >> 3); - } - -#if defined(BOOST_MSVC) -#pragma warning(push) -#if BOOST_MSVC <= 1400 -#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to - // 'unsigned int', possible loss of data - // A misguided attempt to detect 64-bit - // incompatability. -#endif -#endif - - template - inline void hash_combine(std::size_t& seed, T const& v) - { - boost::hash hasher; - return boost::hash_detail::hash_combine_impl(seed, hasher(v)); - } - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - - template - inline std::size_t hash_range(It first, It last) - { - std::size_t seed = 0; - - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - - return seed; - } - - template - inline void hash_range(std::size_t& seed, It first, It last) - { - for(; first != last; ++first) - { - hash_combine(seed, *first); - } - } - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - template - inline std::size_t hash_range(T* first, T* last) - { - std::size_t seed = 0; - - for(; first != last; ++first) - { - boost::hash hasher; - seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - - return seed; - } - - template - inline void hash_range(std::size_t& seed, T* first, T* last) - { - for(; first != last; ++first) - { - boost::hash hasher; - seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - } -#endif - -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - template< class T, unsigned N > - inline std::size_t hash_value(const T (&x)[N]) - { - return hash_range(x, x + N); - } - - template< class T, unsigned N > - inline std::size_t hash_value(T (&x)[N]) - { - return hash_range(x, x + N); - } -#endif - - template - inline std::size_t hash_value( - std::basic_string, A> const& v) - { - return hash_range(v.begin(), v.end()); - } - - template - typename boost::hash_detail::float_numbers::type hash_value(T v) - { - return boost::hash_detail::float_hash_value(v); - } - -#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) - inline std::size_t hash_value(std::type_index v) - { - return v.hash_code(); - } -#endif - - // - // boost::hash - // - - // Define the specializations required by the standard. The general purpose - // boost::hash is defined later in extensions.hpp if - // BOOST_HASH_NO_EXTENSIONS is not defined. - - // BOOST_HASH_SPECIALIZE - define a specialization for a type which is - // passed by copy. - // - // BOOST_HASH_SPECIALIZE_REF - define a specialization for a type which is - // passed by const reference. - // - // These are undefined later. - -#define BOOST_HASH_SPECIALIZE(type) \ - template <> struct hash \ - : public boost::hash_detail::hash_base \ - { \ - std::size_t operator()(type v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; - -#define BOOST_HASH_SPECIALIZE_REF(type) \ - template <> struct hash \ - : public boost::hash_detail::hash_base \ - { \ - std::size_t operator()(type const& v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; - - BOOST_HASH_SPECIALIZE(bool) - BOOST_HASH_SPECIALIZE(char) - BOOST_HASH_SPECIALIZE(signed char) - BOOST_HASH_SPECIALIZE(unsigned char) -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_HASH_SPECIALIZE(wchar_t) -#endif -#if !defined(BOOST_NO_CXX11_CHAR16_T) - BOOST_HASH_SPECIALIZE(char16_t) -#endif -#if !defined(BOOST_NO_CXX11_CHAR32_T) - BOOST_HASH_SPECIALIZE(char32_t) -#endif - BOOST_HASH_SPECIALIZE(short) - BOOST_HASH_SPECIALIZE(unsigned short) - BOOST_HASH_SPECIALIZE(int) - BOOST_HASH_SPECIALIZE(unsigned int) - BOOST_HASH_SPECIALIZE(long) - BOOST_HASH_SPECIALIZE(unsigned long) - - BOOST_HASH_SPECIALIZE(float) - BOOST_HASH_SPECIALIZE(double) - BOOST_HASH_SPECIALIZE(long double) - - BOOST_HASH_SPECIALIZE_REF(std::string) -#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_HASH_SPECIALIZE_REF(std::wstring) -#endif -#if !defined(BOOST_NO_CXX11_CHAR16_T) - BOOST_HASH_SPECIALIZE_REF(std::basic_string) -#endif -#if !defined(BOOST_NO_CXX11_CHAR32_T) - BOOST_HASH_SPECIALIZE_REF(std::basic_string) -#endif - -#if !defined(BOOST_NO_LONG_LONG) - BOOST_HASH_SPECIALIZE(boost::long_long_type) - BOOST_HASH_SPECIALIZE(boost::ulong_long_type) -#endif - -#if defined(BOOST_HAS_INT128) - BOOST_HASH_SPECIALIZE(boost::int128_type) - BOOST_HASH_SPECIALIZE(boost::uint128_type) -#endif - -#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) - BOOST_HASH_SPECIALIZE(std::type_index) -#endif - -#undef BOOST_HASH_SPECIALIZE -#undef BOOST_HASH_SPECIALIZE_REF - -// Specializing boost::hash for pointers. - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - template - struct hash - : public boost::hash_detail::hash_base - { - std::size_t operator()(T* v) const - { -#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) - return boost::hash_value(v); -#else - std::size_t x = static_cast( - reinterpret_cast(v)); - - return x + (x >> 3); -#endif - } - }; - -#else - - // For compilers without partial specialization, we define a - // boost::hash for all remaining types. But hash_impl is only defined - // for pointers in 'extensions.hpp' - so when BOOST_HASH_NO_EXTENSIONS - // is defined there will still be a compile error for types not supported - // in the standard. - - namespace hash_detail - { - template - struct hash_impl; - - template <> - struct hash_impl - { - template - struct inner - : public boost::hash_detail::hash_base - { - std::size_t operator()(T val) const - { -#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) - return boost::hash_value(val); -#else - std::size_t x = static_cast( - reinterpret_cast(val)); - - return x + (x >> 3); -#endif - } - }; - }; - } - - template struct hash - : public boost::hash_detail::hash_impl::value> - ::BOOST_NESTED_TEMPLATE inner - { - }; - -#endif -} - -#undef BOOST_HASH_CHAR_TRAITS -#undef BOOST_FUNCTIONAL_HASH_ROTL32 - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP - -// Include this outside of the include guards in case the file is included -// twice - once with BOOST_HASH_NO_EXTENSIONS defined, and then with it -// undefined. - -#if !defined(BOOST_HASH_NO_EXTENSIONS) \ - && !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) -#include -#endif +#include diff --git a/include/boost/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp index 01fe012..aeffad0 100644 --- a/include/boost/functional/hash/hash_fwd.hpp +++ b/include/boost/functional/hash/hash_fwd.hpp @@ -3,34 +3,4 @@ // 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) -// Based on Peter Dimov's proposal -// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf -// issue 6.18. - -#if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) -#define BOOST_FUNCTIONAL_HASH_FWD_HPP - -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include -#include - -namespace boost -{ - template struct hash; - - template void hash_combine(std::size_t& seed, T const& v); - - template std::size_t hash_range(It, It); - template void hash_range(std::size_t&, It, It); - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - template inline std::size_t hash_range(T*, T*); - template inline void hash_range(std::size_t&, T*, T*); -#endif -} - -#endif +#include diff --git a/include/boost/functional/hash_fwd.hpp b/include/boost/functional/hash_fwd.hpp index eea9073..aeffad0 100644 --- a/include/boost/functional/hash_fwd.hpp +++ b/include/boost/functional/hash_fwd.hpp @@ -3,9 +3,4 @@ // 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) -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include +#include diff --git a/meta/explicit-failures-markup.xml b/meta/explicit-failures-markup.xml index 5f21dd0..7f94140 100644 --- a/meta/explicit-failures-markup.xml +++ b/meta/explicit-failures-markup.xml @@ -1,7 +1,7 @@ - - + + diff --git a/meta/libraries.json b/meta/libraries.json index 22473a4..b1b075b 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -2,14 +2,14 @@ { "key": "functional/hash", "boost-version": "1.33.0", - "name": "Functional/Hash", + "name": "Container Hash", "authors": [ "Daniel James" ], "maintainers": [ "Daniel James " ], - "description": "A TR1 hash function object that can be extended to hash user defined types.", + "description": "An STL-compatible hash function object that can be extended to hash user defined types.", "std": [ "tr1" ], @@ -17,4 +17,4 @@ "Function-objects" ] } -] \ No newline at end of file +] diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1da2da8..dd2b977 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,7 +18,7 @@ project hash-tests #darwin:on ; -test-suite functional/hash +test-suite container_hash/hash : [ compile check_float_funcs.cpp ] [ run hash_fwd_test_1.cpp ] @@ -56,7 +56,7 @@ test-suite functional/hash [ run hash_no_ext_macro_2.cpp ] ; -test-suite functional/hash_no_ext +test-suite container_hash/hash_no_ext : [ run hash_number_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_number_test ] [ run hash_pointer_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_pointer_test ] @@ -69,7 +69,7 @@ test-suite functional/hash_no_ext # Tests to see if the floating point hash is using the binary hash. # Not run normally because on some platforms these should fail. -test-suite functional/hash_no_generic_float +test-suite container_hash/hash_no_generic_float : [ run hash_float_test.cpp : : : BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC @@ -78,6 +78,6 @@ test-suite functional/hash_no_generic_float : : : BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC : hash_long_double_test_no_generic ] ; -explicit functional/hash_no_generic_float ; +explicit container_hash/hash_no_generic_float ; build-project ../examples ; diff --git a/test/config.hpp b/test/config.hpp index 53edf0a..28b28d4 100644 --- a/test/config.hpp +++ b/test/config.hpp @@ -18,4 +18,8 @@ // before doing anything else. #pragma warning(disable:4201) // nonstandard extension used : // nameless struct/union + #endif + +#define HASH_TEST_CAT(x, y) HASH_TEST_CAT2(x, y) +#define HASH_TEST_CAT2(x, y) x##y diff --git a/test/extensions_hpp_test.cpp b/test/extensions_hpp_test.cpp index c27981a..54d1054 100644 --- a/test/extensions_hpp_test.cpp +++ b/test/extensions_hpp_test.cpp @@ -3,14 +3,14 @@ // 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) -// Check that boost/functional/hash/extensions.hpp works okay. +// Check that boost/container_hash/hash/extensions.hpp works okay. // -// It probably should be in boost/functional/hash/detail, but since it isn't it +// It probably should be in boost/container_hash/hash/detail, but since it isn't it // should work. #include "./config.hpp" -#include +#include int main() { int x[2] = { 2, 3 }; diff --git a/test/hash_built_in_array_test.cpp b/test/hash_built_in_array_test.cpp index e2dfe99..ac782c3 100644 --- a/test/hash_built_in_array_test.cpp +++ b/test/hash_built_in_array_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_complex_test.cpp b/test/hash_complex_test.cpp index 88f3833..5ecacbf 100644 --- a/test/hash_complex_test.cpp +++ b/test/hash_complex_test.cpp @@ -14,10 +14,10 @@ int main() {} #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #if defined(BOOST_MSVC) #pragma warning(disable:4244) // conversion from 'unsigned long' to diff --git a/test/hash_custom_test.cpp b/test/hash_custom_test.cpp index 4f125ab..a642f0e 100644 --- a/test/hash_custom_test.cpp +++ b/test/hash_custom_test.cpp @@ -45,11 +45,11 @@ namespace boost # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_deque_test.cpp b/test/hash_deque_test.cpp index 4d7f447..3b900b8 100644 --- a/test/hash_deque_test.cpp +++ b/test/hash_deque_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_enum_test.cpp b/test/hash_enum_test.cpp index 2872b43..3d725b7 100644 --- a/test/hash_enum_test.cpp +++ b/test/hash_enum_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include "./compile_time.hpp" namespace test { diff --git a/test/hash_float_test.hpp b/test/hash_float_test.hpp index 8c2a43a..a73c31f 100644 --- a/test/hash_float_test.hpp +++ b/test/hash_float_test.hpp @@ -8,15 +8,15 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/hash_friend_test.cpp b/test/hash_friend_test.cpp index 4b75f8a..60d172e 100644 --- a/test/hash_friend_test.cpp +++ b/test/hash_friend_test.cpp @@ -48,11 +48,11 @@ namespace boost # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_function_pointer_test.cpp b/test/hash_function_pointer_test.cpp index 50fedf7..abc8c4a 100644 --- a/test/hash_function_pointer_test.cpp +++ b/test/hash_function_pointer_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include "./compile_time.hpp" void void_func1() { static int x = 1; ++x; } diff --git a/test/hash_fwd_test.hpp b/test/hash_fwd_test.hpp index d3c8186..76fce57 100644 --- a/test/hash_fwd_test.hpp +++ b/test/hash_fwd_test.hpp @@ -6,7 +6,7 @@ #include "./config.hpp" #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) -#include +#include #include #include diff --git a/test/hash_fwd_test_1.cpp b/test/hash_fwd_test_1.cpp index 68fdde2..70ab3c7 100644 --- a/test/hash_fwd_test_1.cpp +++ b/test/hash_fwd_test_1.cpp @@ -9,11 +9,11 @@ #include "./hash_fwd_test.hpp" -#include +#include #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) -#include +#include #include void fwd_test1() diff --git a/test/hash_fwd_test_2.cpp b/test/hash_fwd_test_2.cpp index d4c1a32..44f07c4 100644 --- a/test/hash_fwd_test_2.cpp +++ b/test/hash_fwd_test_2.cpp @@ -15,7 +15,7 @@ int main() {} #else #include "./hash_fwd_test.hpp" -#include +#include template void unused(T const&) {} diff --git a/test/hash_global_namespace_test.cpp b/test/hash_global_namespace_test.cpp index 7fc7bf6..6062ba9 100644 --- a/test/hash_global_namespace_test.cpp +++ b/test/hash_global_namespace_test.cpp @@ -46,11 +46,11 @@ namespace boost # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_list_test.cpp b/test/hash_list_test.cpp index a0f9716..9b2c25f 100644 --- a/test/hash_list_test.cpp +++ b/test/hash_list_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_map_test.cpp b/test/hash_map_test.cpp index 01a7854..b70a9be 100644 --- a/test/hash_map_test.cpp +++ b/test/hash_map_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #include diff --git a/test/hash_map_test.hpp b/test/hash_map_test.hpp index 41bb2fa..95ca62c 100644 --- a/test/hash_map_test.hpp +++ b/test/hash_map_test.hpp @@ -7,15 +7,13 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4244) // conversion from 'int' to 'float' #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -59,7 +57,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/test/hash_no_ext_fail_test.cpp b/test/hash_no_ext_fail_test.cpp index 6d1636e..ee35950 100644 --- a/test/hash_no_ext_fail_test.cpp +++ b/test/hash_no_ext_fail_test.cpp @@ -14,7 +14,7 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif template void ignore(T const&) {} diff --git a/test/hash_no_ext_macro_1.cpp b/test/hash_no_ext_macro_1.cpp index d69e5b5..1bfcb95 100644 --- a/test/hash_no_ext_macro_1.cpp +++ b/test/hash_no_ext_macro_1.cpp @@ -11,14 +11,14 @@ # if defined(BOOST_HASH_NO_EXTENSIONS) # undef BOOST_HASH_NO_EXTENSIONS # endif -# include +# include // Include header with BOOST_HASH_NO_EXTENSIONS defined # define BOOST_HASH_NO_EXTENSIONS -# include +# include #endif -#include +#include #include int main() diff --git a/test/hash_no_ext_macro_2.cpp b/test/hash_no_ext_macro_2.cpp index fe548ee..6f46018 100644 --- a/test/hash_no_ext_macro_2.cpp +++ b/test/hash_no_ext_macro_2.cpp @@ -11,14 +11,14 @@ # if !defined(BOOST_HASH_NO_EXTENSIONS) # define BOOST_HASH_NO_EXTENSIONS # endif -# include +# include // Include header without BOOST_HASH_NO_EXTENSIONS defined # undef BOOST_HASH_NO_EXTENSIONS -# include +# include #endif -#include +#include #include int main() diff --git a/test/hash_number_test.cpp b/test/hash_number_test.cpp index 18756c3..c78783e 100644 --- a/test/hash_number_test.cpp +++ b/test/hash_number_test.cpp @@ -8,15 +8,14 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif #include -#include +#include -#include -#include -#include +#include +#include #include "./compile_time.hpp" @@ -140,7 +139,7 @@ void bool_test() { BOOST_HASH_TEST_NAMESPACE::hash x1; BOOST_HASH_TEST_NAMESPACE::hash x2; - + BOOST_TEST(x1(true) == x2(true)); BOOST_TEST(x1(false) == x2(false)); BOOST_TEST(x1(true) != x2(false)); diff --git a/test/hash_pointer_test.cpp b/test/hash_pointer_test.cpp index 7cacaa8..7086a61 100644 --- a/test/hash_pointer_test.cpp +++ b/test/hash_pointer_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include #include "./compile_time.hpp" diff --git a/test/hash_range_test.cpp b/test/hash_range_test.cpp index a5bdbb6..4a309e3 100644 --- a/test/hash_range_test.cpp +++ b/test/hash_range_test.cpp @@ -14,10 +14,10 @@ int main() {} #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include #include diff --git a/test/hash_sequence_test.hpp b/test/hash_sequence_test.hpp index 30083f9..3e915f8 100644 --- a/test/hash_sequence_test.hpp +++ b/test/hash_sequence_test.hpp @@ -7,14 +7,12 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -61,7 +59,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/test/hash_set_test.cpp b/test/hash_set_test.cpp index 1cf9fef..48dcc2b 100644 --- a/test/hash_set_test.cpp +++ b/test/hash_set_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_set_test.hpp b/test/hash_set_test.hpp index 0a90330..9a77756 100644 --- a/test/hash_set_test.hpp +++ b/test/hash_set_test.hpp @@ -7,14 +7,12 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -64,7 +62,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/test/hash_std_array_test.cpp b/test/hash_std_array_test.cpp index 2b240a3..d8faee4 100644 --- a/test/hash_std_array_test.cpp +++ b/test/hash_std_array_test.cpp @@ -9,12 +9,12 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif #include -#include +#include #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_ARRAY) #define TEST_ARRAY diff --git a/test/hash_std_smart_ptr_test.cpp b/test/hash_std_smart_ptr_test.cpp index feb09d9..b8625fe 100644 --- a/test/hash_std_smart_ptr_test.cpp +++ b/test/hash_std_smart_ptr_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include "./compile_time.hpp" #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_SMART_PTR) diff --git a/test/hash_std_tuple_test.cpp b/test/hash_std_tuple_test.cpp index 97bea99..df4ef37 100644 --- a/test/hash_std_tuple_test.cpp +++ b/test/hash_std_tuple_test.cpp @@ -9,12 +9,12 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif #include -#include +#include #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_TUPLE) #define TEST_TUPLE diff --git a/test/hash_string_test.cpp b/test/hash_string_test.cpp index 7088d67..f84eb74 100644 --- a/test/hash_string_test.cpp +++ b/test/hash_string_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif -#include +#include #include #include "./compile_time.hpp" diff --git a/test/hash_type_index_test.cpp b/test/hash_type_index_test.cpp index 3288a5b..f03750f 100644 --- a/test/hash_type_index_test.cpp +++ b/test/hash_type_index_test.cpp @@ -8,10 +8,10 @@ #ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else -# include +# include #endif #include -#include +#include #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) diff --git a/test/hash_value_array_test.cpp b/test/hash_value_array_test.cpp index 58fc447..d0d7fe6 100644 --- a/test/hash_value_array_test.cpp +++ b/test/hash_value_array_test.cpp @@ -12,11 +12,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_vector_test.cpp b/test/hash_vector_test.cpp index 6dcf3b0..752438f 100644 --- a/test/hash_vector_test.cpp +++ b/test/hash_vector_test.cpp @@ -9,11 +9,11 @@ # ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else -# include +# include # endif #endif -#include +#include #ifdef BOOST_HASH_TEST_EXTENSIONS diff --git a/test/implicit_test.cpp b/test/implicit_test.cpp index e48bbcd..67859da 100644 --- a/test/implicit_test.cpp +++ b/test/implicit_test.cpp @@ -3,7 +3,7 @@ // 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) -#include +#include namespace test { diff --git a/test/link_ext_test.cpp b/test/link_ext_test.cpp index 74a4eb5..de4964b 100644 --- a/test/link_ext_test.cpp +++ b/test/link_ext_test.cpp @@ -6,8 +6,8 @@ #include "./config.hpp" #define BOOST_HASH_TEST_NAMESPACE boost -#include -#include +#include +#include #include int f(std::size_t hash1, int* x1) { diff --git a/test/link_no_ext_test.cpp b/test/link_no_ext_test.cpp index 75cd47d..b325bd6 100644 --- a/test/link_no_ext_test.cpp +++ b/test/link_no_ext_test.cpp @@ -7,8 +7,8 @@ #define BOOST_HASH_TEST_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS -#include -#include +#include +#include extern int f(std::size_t, int*); diff --git a/test/link_test.cpp b/test/link_test.cpp index bdae262..4acc301 100644 --- a/test/link_test.cpp +++ b/test/link_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#include +#include extern int f(); int main() { return f(); } diff --git a/test/link_test_2.cpp b/test/link_test_2.cpp index 1beffc8..ff50e52 100644 --- a/test/link_test_2.cpp +++ b/test/link_test_2.cpp @@ -5,6 +5,6 @@ #include "./config.hpp" -#include +#include int f() { return 0; } diff --git a/test/namespace_fail_test.cpp b/test/namespace_fail_test.cpp index 1db9fc6..700d074 100644 --- a/test/namespace_fail_test.cpp +++ b/test/namespace_fail_test.cpp @@ -9,7 +9,7 @@ #include "./config.hpp" #include -#include +#include typedef list foo;