diff --git a/.travis.yml b/.travis.yml index 5edf19f..0c7f812 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,13 +64,12 @@ before_script: cd $HOME/extract tar -xjf $HOME/download/boost.tar.bz2 mv * ${BOOST_ROOT} - - rm -r ${BOOST_ROOT}/boost/functional + - rm ${BOOST_ROOT}/boost/functional.hpp + - find ${BOOST_ROOT}/boost/functional -type f | grep -v hash | xargs -r rm script: - cd ${TRAVIS_BUILD_DIR}/test - bjam -q ${BJAM_TOOLSET} include=${BOOST_ROOT} include=${TRAVIS_BUILD_DIR}/include - - cd ${TRAVIS_BUILD_DIR}/hash/test - - bjam -q ${BJAM_TOOLSET} include=${BOOST_ROOT} include=${TRAVIS_BUILD_DIR}/include - cd ${TRAVIS_BUILD_DIR}/forward/test - bjam -q ${BJAM_TOOLSET} include=${BOOST_ROOT} include=${TRAVIS_BUILD_DIR}/include - cd ${TRAVIS_BUILD_DIR}/factory/test diff --git a/doc/build.jam b/doc/build.jam index c96db00..0800f65 100644 --- a/doc/build.jam +++ b/doc/build.jam @@ -5,11 +5,7 @@ # http://www.boost.org/LICENSE_1_0.txt) ############################################################################### -alias boostdoc - : ../hash/doc//hash - : - : - : ; +alias boostdoc ; explicit boostdoc ; alias boostrelease : ../factory/doc//standalone diff --git a/factory/test/Jamfile b/factory/test/Jamfile index fe5041f..c4a06af 100644 --- a/factory/test/Jamfile +++ b/factory/test/Jamfile @@ -14,9 +14,11 @@ test-suite functional/factory [ run value_factory.cpp ] [ run factory.cpp ] [ run factory_with_allocator.cpp ] + [ run factory_with_std_allocator.cpp ] [ compile-fail factory_with_none_t.cpp ] [ run factory.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory ] [ run factory_with_allocator.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_allocator ] + [ run factory_with_std_allocator.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_std_allocator ] [ run factory_with_none_t.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_none_t ] ; diff --git a/factory/test/factory.cpp b/factory/test/factory.cpp index 6894481..ef895cf 100644 --- a/factory/test/factory.cpp +++ b/factory/test/factory.cpp @@ -7,7 +7,7 @@ ==============================================================================*/ #include -#include +#include #include diff --git a/factory/test/factory_with_allocator.cpp b/factory/test/factory_with_allocator.cpp index decd656..c1eef65 100644 --- a/factory/test/factory_with_allocator.cpp +++ b/factory/test/factory_with_allocator.cpp @@ -7,12 +7,17 @@ ==============================================================================*/ #include -#include +#include #include #include #include +#ifdef BOOST_MSVC +// none of the deprecated members of std::allocate are used here +# pragma warning(disable:4996) // Various members of std::allocator are deprecated in C++17 +#endif + using std::size_t; class sum diff --git a/factory/test/factory_with_none_t.cpp b/factory/test/factory_with_none_t.cpp index bdca2c2..e8a515a 100644 --- a/factory/test/factory_with_none_t.cpp +++ b/factory/test/factory_with_none_t.cpp @@ -7,7 +7,7 @@ ==============================================================================*/ #include -#include +#include #include #include diff --git a/factory/test/factory_with_std_allocator.cpp b/factory/test/factory_with_std_allocator.cpp new file mode 100644 index 0000000..2a58a60 --- /dev/null +++ b/factory/test/factory_with_std_allocator.cpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2007 Tobias Schwinger + Copyright (c) 2017 Daniel James + + Use modification and distribution are subject to 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 + +#include +#include +#include + +class sum +{ + int val_sum; + public: + sum(int a, int b) : val_sum(a + b) { } + + operator int() const { return this->val_sum; } +}; + +int main() +{ + int one = 1, two = 2; + { + boost::shared_ptr instance( + boost::factory< boost::shared_ptr, std::allocator, + boost::factory_alloc_for_pointee_and_deleter >()(one,two) ); + BOOST_TEST(*instance == 3); + } + + { + boost::shared_ptr instance( + boost::factory< boost::shared_ptr, std::allocator, + boost::factory_passes_alloc_to_smart_pointer >()(one,two) ); + BOOST_TEST(*instance == 3); + } + + return boost::report_errors(); +} + diff --git a/factory/test/value_factory.cpp b/factory/test/value_factory.cpp index e63c9ec..331757d 100644 --- a/factory/test/value_factory.cpp +++ b/factory/test/value_factory.cpp @@ -7,7 +7,7 @@ ==============================================================================*/ #include -#include +#include class sum { diff --git a/forward/test/forward_adapter.cpp b/forward/test/forward_adapter.cpp index 09cef7e..0c5e0c3 100644 --- a/forward/test/forward_adapter.cpp +++ b/forward/test/forward_adapter.cpp @@ -12,7 +12,7 @@ # pragma warning(disable: 4244) // no conversion warnings, please #endif -#include +#include #include #include diff --git a/forward/test/lightweight_forward_adapter.cpp b/forward/test/lightweight_forward_adapter.cpp index dbd0f3f..b89c92a 100644 --- a/forward/test/lightweight_forward_adapter.cpp +++ b/forward/test/lightweight_forward_adapter.cpp @@ -12,7 +12,7 @@ # pragma warning(disable: 4244) // no conversion warnings, please #endif -#include +#include #include #include diff --git a/hash/doc/Jamfile.v2 b/hash/doc/Jamfile.v2 deleted file mode 100644 index 62e2798..0000000 --- a/hash/doc/Jamfile.v2 +++ /dev/null @@ -1,19 +0,0 @@ - -# Copyright 2005-2008 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) - -using boostbook ; -using quickbook ; - -xml hash : hash.qbk ; -boostbook standalone : hash : - boost.root=../../../../.. - - chunk.first.sections=1 - chunk.section.depth=2 - 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 - ; diff --git a/hash/doc/changes.qbk b/hash/doc/changes.qbk deleted file mode 100644 index 37dd738..0000000 --- a/hash/doc/changes.qbk +++ /dev/null @@ -1,204 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[template ticket[number]''''''#[number]''''''] - -[section:changes Change Log] - -[h2 Boost 1.33.0] - -* Initial Release - -[h2 Boost 1.33.1] - -* Fixed the points example, as pointed out by 沈慧峰. - -[h2 Boost 1.34.0] - -* 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. -* Add support for the `BOOST_HASH_NO_EXTENSIONS` macro, which - disables the extensions to TR1. - -* Minor improvements to the hash functions for floating point numbers. -* Update the portable example to hopefully be more generally portable. - -[h2 Boost 1.34.1] - -* [@http://svn.boost.org/trac/boost/ticket/952 Ticket 952]: - Suppress incorrect 64-bit warning on Visual C++. - -[h2 Boost 1.35.0] - -* Support for `long long`, `std::complex`. -* Improved algorithm for hashing floating point numbers: - * Improved portablity, as described by Daniel Krügler in - [@http://lists.boost.org/boost-users/2005/08/13418.php - a post to the boost users list]. - * Fits more information into each combine loop, which can reduce the - the number of times combine is called and hopefully give a better - quality hash function. - * Improved the algorithm for hashing floating point numbers. - * On Cygwin use a binary hash function for floating point numbers, as - Cygwin doesn't have decent floating point functions for `long double`. - * Never uses `fpclass` which doesn't support `long double`. - * [@http://svn.boost.org/trac/boost/ticket/1064 Ticket 1064]: - Removed unnecessary use of `errno`. -* Explicitly overload for more built in types. -* Minor improvements to the documentation. -* A few bug and warning fixes: - * [@http://svn.boost.org/trac/boost/ticket/1509 Ticket 1509]: - Suppress another Visual C++ warning. - * Some workarounds for the Sun compilers. - -[h2 Boost 1.36.0] - -* Stop using OpenBSD's dodgy `std::numeric_limits`. -* Using the boost typedefs for `long long` and `unsigned long long`. -* Move the extensions into their own header. - -[h2 Boost 1.37.0] - -* [@http://svn.boost.org/trac/boost/ticket/2264 Ticket 2264]: - In Visual C++, always use C99 float functions for `long double` and `float` as - the C++ overloads aren't always availables. - -[h2 Boost 1.38.0] - -* 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` - 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`. - -[h2 Boost 1.39.0] - -* Move the hash_fwd.hpp implementation into the hash subdirectory, leaving a - forwarding header in the old location. You should still use the old location, - the new location is mainly for implementation and possible modularization. -* [@https://svn.boost.org/trac/boost/ticket/2412 Ticket 2412]: Removed deprecated - headers. -* [@https://svn.boost.org/trac/boost/ticket/2957 Ticket 2957]: Fix configuration - for vxworks. - -[h2 Boost 1.40.0] - -* Automatically configure the float functions using template metaprogramming - instead of trying to configure every possibility manually. -* Workaround for when STLport doesn't support long double. - -[h2 Boost 1.42.0] - -* Reduce the number of warnings for Visual C++ warning level 4. -* Some code formatting changes to fit lines into 80 characters. -* Rename an internal namespace. - -[h2 Boost 1.43.0] - -* [@https://svn.boost.org/trac/boost/ticket/3866 Ticket 3866]: - Don't foward declare containers when using gcc's parallel library, - allow user to stop forward declaration by defining the - `BOOST_DETAIL_NO_CONTAINER_FWD` macro. -* [@https://svn.boost.org/trac/boost/ticket/4038 Ticket 4038]: - Avoid hashing 0.5 and 0 to the same number. -* Stop using deprecated `BOOST_HAS_*` macros. - -[h2 Boost 1.44.0] - -* Add option to prevent implicit conversions when calling `hash_value` by - defining `BOOST_HASH_NO_IMPLICIT_CASTS`. When using `boost::hash` - for a type that does not have `hash_value` declared but does have - an implicit conversion to a type that does, it would use that - implicit conversion to hash it. Which can sometimes go very wrong, - e.g. using a conversion to bool and only hashing to 2 possible - values. Since fixing this is a breaking change and was only - approached quite late in the release cycle with little discussion - it's opt-in for now. This, or something like it, will become the - default in a future version. - -[h2 Boost 1.46.0] - -* Avoid warning due with gcc's `-Wconversion` flag. - -[h2 Boost 1.50.0] - -* [@http://svn.boost.org/trac/boost/ticket/6771 Ticket 6771]: - Avoid gcc's `-Wfloat-equal` warning. -* [@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`. - -[h2 Boost 1.51.0] - -* Support the standard smart pointers. -* `hash_value` now implemented using SFINAE to avoid implicit casts to built - in types when calling it. -* Updated to use the new config macros. - -[h2 Boost 1.52.0] - -* Restore `enum` support, which was accidentally removed in the last version. -* New floating point hasher - will hash the binary representation on more - platforms, which should be faster. - -[h2 Boost 1.53.0] - -* Add support for `boost::int128_type` and `boost::uint128_type` where - available - currently only `__int128` and `unsigned __int128` on some - versions of gcc. -* On platforms that are known to have the standard floating point functions, - don't use automatic detection - which can break if there are ambiguous - overloads. -* Fix undefined behaviour when using the binary float hash (Thomas Heller). - -[h2 Boost 1.54.0] - -* [@https://svn.boost.org/trac/boost/ticket/7957 Ticket 7957]: - Fixed a typo. - -[h2 Boost 1.55.0] - -* Simplify a SFINAE check so that it will hopefully work on Sun 5.9 - ([ticket 8822]). -* Suppress Visual C++ infinite loop warning ([ticket 8568]). - -[h2 Boost 1.56.0] - -* Removed some Visual C++ 6 workarounds. -* Ongoing work on improving `hash_combine`. This changes the combine function - which was previously defined in the reference documentation. - -[h2 Boost 1.58.0] - -* Fixed strict aliasing violation - ([@https://github.com/boostorg/functional/pull/3 GitHub #3]). - -[h2 Boost 1.63.0] - -* Fixed some warnings. -* Only define hash for `std::wstring` when we know we have a `wchar_t`. - Otherwise there's a compile error as there's no overload for hashing - the characters in wide strings ([ticket 8552]). - -[h2 Boost 1.64.0] - -* Fix for recent versions of Visual C++ which have removed `std::unary_function` - and `std::binary_function` ([ticket 12353]). - -[h2 Boost 1.65.0] - -* Support for `char16_t`, `char32_t`, `u16string`, `u32string` - -[h2 Boost 1.66.0] - -* Avoid float comparison warning when using Clang - this workaround was - already in place for GCC, and was used when Clang pretends to be GCC, - but the warning was appearing when running Clang in other contexts. - -[endsect] diff --git a/hash/doc/disable.qbk b/hash/doc/disable.qbk deleted file mode 100644 index 27dec6b..0000000 --- a/hash/doc/disable.qbk +++ /dev/null @@ -1,29 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[section:disable Disabling The Extensions] - -While [classref boost::hash]'s extensions are generally useful, you might want -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 -- activating the extensions. - -It is strongly recommended that you never undefine the macro - and only define -it so that it applies to the complete translation unit, either by defining it -at the beginning of the main source file or, preferably, by using a compiler -switch or preference. And you really should never define it in header files. - -If you are writing a library which has code in the header which requires the -extensions, then the best action is to tell users not to define the macro. -Their code won't ['require] the macro. - -Translation units that are compiled with the macro defined will link with units -that were compiled without it. This feature has been designed to avoid ODR -violations. - -[endsect] diff --git a/hash/doc/hash.qbk b/hash/doc/hash.qbk deleted file mode 100644 index cdb72d4..0000000 --- a/hash/doc/hash.qbk +++ /dev/null @@ -1,29 +0,0 @@ -[library Boost.Functional/Hash - [quickbook 1.5] - [authors [James, Daniel]] - [copyright 2005 2006 2007 2008 Daniel James] - [purpose A TR1 hash function object that can be extended to hash user - defined types] - [category higher-order] - [id hash] - [dirname functional/hash] - [license - 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]) - ] -] - -[def __issues__ - [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf - Library Extension Technical Report Issues List]] - -[include:hash intro.qbk] -[include:hash tutorial.qbk] -[include:hash portability.qbk] -[include:hash disable.qbk] -[include:hash changes.qbk] -[include:hash rationale.qbk] -[xinclude ref.xml] -[include:hash links.qbk] -[include:hash thanks.qbk] diff --git a/hash/doc/intro.qbk b/hash/doc/intro.qbk deleted file mode 100644 index 076e997..0000000 --- a/hash/doc/intro.qbk +++ /dev/null @@ -1,52 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[section:intro Introduction] - -[def __tr1-full__ - [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf - Draft Technical Report on C++ Library Extensions]] -[def __tr1__ - [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf - TR1]] -[def __unordered__ [link unordered Boost.Unordered]] -[def __intrusive__ [link intrusive.unordered_set_unordered_multiset Boost.Intrusive]] -[def __multi-index__ [@boost:/libs/multi_index/doc/index.html - Boost Multi-Index Containers Library]] -[def __multi-index-short__ [@boost:/libs/multi_index/doc/index.html - Boost.MultiIndex]] -[def __bimap__ [@boost:/libs/bimap/index.html Boost.Bimap]] -[def __hash-function__ [@http://en.wikipedia.org/wiki/Hash_function hash function]] -[def __hash-table__ [@http://en.wikipedia.org/wiki/Hash_table hash table]] - -[classref boost::hash] is an implementation of the __hash-function__ object -specified by the __tr1-full__ (TR1). It is the default hash function for -__unordered__, __intrusive__'s unordered associative containers, and -__multi-index-short__'s hash indicies and __bimap__'s `unordered_set_of`. - -As it is compliant with __tr1__, it will work with: - -* integers -* floats -* pointers -* strings - -It also implements the extension proposed by Peter Dimov in issue 6.18 of the -__issues__ (page 63), this adds support for: - -* arrays -* `std::pair` -* the standard containers. -* extending [classref boost::hash] for custom types. - -[note -This hash function is designed to be used in containers based on -the STL and is not suitable as a general purpose hash function. -For more details see the [link hash.rationale rationale]. -] - - -[endsect] - diff --git a/hash/doc/links.qbk b/hash/doc/links.qbk deleted file mode 100644 index 405536e..0000000 --- a/hash/doc/links.qbk +++ /dev/null @@ -1,27 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[section:links Links] - -[*A Proposal to Add Hash Tables to the Standard Library] -[@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2003/n1456.html] -The hash table proposal explains much of the design. The hash function object -is discussed in Section D. - -[*The C++ Standard Library Technical Report.] -[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf] -Contains the hash function specification in section 6.3.2. - -[*Library Extension Technical Report Issues List.] -[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf] -The library implements the extension described in Issue 6.18, pages 63-67. - -[*Methods for Identifying Versioned and Plagiarised Documents] -Timothy C. Hoad, Justin Zobel -[@http://www.cs.rmit.edu.au/~jz/fulltext/jasist-tch.pdf] -Contains the hash function that [funcref boost::hash_combine] is based on. - -[endsect] - diff --git a/hash/doc/portability.qbk b/hash/doc/portability.qbk deleted file mode 100644 index a65bc19..0000000 --- a/hash/doc/portability.qbk +++ /dev/null @@ -1,93 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[section:portability Portability] - -[def __boost_hash__ [classref boost::hash]] - -__boost_hash__ is written to be as portable as possible, but unfortunately, several -older compilers don't support argument dependent lookup (ADL) - the mechanism -used for customisation. On those compilers custom overloads for `hash_value` -needs to be declared in the boost namespace. - -On a strictly standards compliant compiler, an overload defined in the -boost namespace won't be found when __boost_hash__ is instantiated, -so for these compilers the overload should only be declared in the same -namespace as the class. - -Let's say we have a simple custom type: - - namespace foo - { - template - class custom_type - { - T value; - public: - custom_type(T x) : value(x) {} - - friend std::size_t hash_value(custom_type x) - { - __boost_hash__ hasher; - return hasher(x.value); - } - }; - } - -On a compliant compiler, when `hash_value` is called for this type, -it will look at the namespace inside the type and find `hash_value` -but on a compiler which doesn't support ADL `hash_value` won't be found. -To make things worse, some compilers which do support ADL won't find -a friend class defined inside the class. - -So first move the member function out of the class: - - namespace foo - { - template - class custom_type - { - T value; - public: - custom_type(T x) : value(x) {} - - std::size_t hash(custom_type x) - { - __boost_hash__ hasher; - return hasher(value); - } - }; - - template - inline std::size_t hash_value(custom_type x) - { - return x.hash(); - } - } - -Unfortunately, I couldn't declare hash_value as a friend, as some compilers -don't support template friends, so instead I declared a member function to -calculate the hash, and called it from hash_value. - -For compilers which don't support ADL, hash_value needs to be defined in the -boost namespace: - - #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP - namespace boost - #else - namespace foo - #endif - { - template - std::size_t hash_value(foo::custom_type x) - { - return x.hash(); - } - } - -Full code for this example is at -[@boost:/libs/functional/hash/examples/portable.cpp /libs/functional/hash/examples/portable.cpp]. - -[endsect] diff --git a/hash/doc/rationale.qbk b/hash/doc/rationale.qbk deleted file mode 100644 index 76ff6d1..0000000 --- a/hash/doc/rationale.qbk +++ /dev/null @@ -1,50 +0,0 @@ - -[/ Copyright 2011 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) ] - -[section:rationale Rationale] - -The rationale can be found in the original design -[footnote issue 6.18 of the __issues__ (page 63)]. - -[heading Quality of the hash function] - -Many hash functions strive to have little correlation between the input -and output values. They attempt to uniformally distribute the output -values for very similar inputs. This hash function makes no such -attempt. In fact, for integers, the result of the hash function is often -just the input value. So similar but different input values will often -result in similar but different output values. -This means that it is not appropriate as a general hash function. For -example, a hash table may discard bits from the hash function resulting -in likely collisions, or might have poor collision resolution when hash -values are clustered together. In such cases this hash function will -preform poorly. - -But the standard has no such requirement for the hash function, -it just requires that the hashes of two different values are unlikely -to collide. Containers or algorithms -designed to work with the standard hash function will have to be -implemented to work well when the hash function's output is correlated -to its input. Since they are paying that cost a higher quality hash function -would be wasteful. - -For other use cases, if you do need a higher quality hash function, -then neither the standard hash function or `boost::hash` are appropriate. -There are several options -available. One is to use a second hash on the output of this hash -function, such as [@http://web.archive.org/web/20121102023700/http://www.concentric.net/~Ttwang/tech/inthash.htm -Thomas Wang's hash function]. This this may not work as -well as a hash algorithm tailored for the input. - -For strings there are several fast, high quality hash functions -available (for example [@http://code.google.com/p/smhasher/ MurmurHash3] -and [@http://code.google.com/p/cityhash/ Google's CityHash]), -although they tend to be more machine specific. -These may also be appropriate for hashing a binary representation of -your data - providing that all equal values have an equal -representation, which is not always the case (e.g. for floating point -values). - -[endsect] diff --git a/hash/doc/ref.xml b/hash/doc/ref.xml deleted file mode 100644 index f5fd185..0000000 --- a/hash/doc/ref.xml +++ /dev/null @@ -1,994 +0,0 @@ - - - - -
- For the full specification, see section 6.3 of the - C++ Standard Library Technical Report - and issue 6.18 of the - Library Extension Technical Report Issues List (page 63). - -
-
- - Defines boost::hash, - and helper functions. - - - - - - - - - - - std::unary_function<T, std::size_t> - - - A TR1 compliant hash function object. - - - std::size_t - - T const& - - - hash_value(val) - - - - The call to hash_value - is unqualified, so that custom overloads can be - found via argument dependent lookup. - - - This is not defined when the macro BOOST_HASH_NO_EXTENSIONS - is defined. The specializations are still defined, so only the specializations - required by TR1 are defined. - - - Forward declared in - <boost/functional/hash_fwd.hpp> - - - This hash function is not intended for general use, and isn't - guaranteed to be equal during separate runs of a program - so - please don't use it for any persistent storage or communication. - - - - Only throws if - hash_value(T) throws. - - - - - - - - bool - - - std::size_t - - bool - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - char - - - std::size_t - - char - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - signed char - - - std::size_t - - signed char - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - unsigned char - - - std::size_t - - unsigned char - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - wchar_t - - - std::size_t - - wchar_t - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - char16_t - - - std::size_t - - char16_t - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - char32_t - - - std::size_t - - char32_t - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - short - - - std::size_t - - short - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - unsigned short - - - std::size_t - - unsigned short - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - int - - - std::size_t - - int - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - unsigned int - - - std::size_t - - unsigned int - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - long - - - std::size_t - - long - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - unsigned long - - - std::size_t - - unsigned long - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - long long - - - std::size_t - - long long - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - unsigned long long - - - std::size_t - - unsigned long long - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - float - - - std::size_t - - float - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - double - - - std::size_t - - double - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - long double - - - std::size_t - - long double - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - std::string - - - std::size_t - - std::string const& - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - std::wstring - - - std::size_t - - std::wstring const& - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - std::u16string - - - std::size_t - - std::u16string const& - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - std::u32string - - - std::size_t - - std::u32string const& - - - Unspecified in TR1, except that equal arguments yield the same result. - hash_value(val) in Boost. - - Doesn't throw - - - - - - - T* - - - std::size_t - - T* - - - Unspecified in TR1, except that equal arguments yield the same result. - - Doesn't throw - - - - - - - std::type_index - - - std::size_t - - std::type_index - - - val.hash_code() - - Doesn't throw - - - - Only available if it's in your standard library and Boost.Config - is aware of it. - - - - - - - - - - - void - size_t & - T const& - - Called repeatedly to incrementally create a hash value from - several variables. - - - Updates seed with a new hash value generated by - combining it with the result of - hash_value(v). Will - always produce the same result for the same combination of - seed and - hash_value(v) during - the single run of a program. - - - hash_value is called without - qualification, so that overloads can be found via ADL. - This is an extension to TR1 - - Forward declared in - <boost/functional/hash_fwd.hpp> - - - This hash function is not intended for general use, and isn't - guaranteed to be equal during separate runs of a program - so - please don't use it for any persistent storage or communication. - - - - Only throws if hash_value(T) throws. - Strong exception safety, as long as hash_value(T) - also has strong exception safety. - - - - - - - - - std::size_t - It - It - - - - - void - std::size_t& - It - It - - - - Calculate the combined hash value of the elements of an iterator - range. - - - For the two argument overload: - -size_t seed = 0; - -for(; first != last; ++first) -{ - hash_combine(seed, *first); -} - -return seed; - - - For the three arguments overload: - -for(; first != last; ++first) -{ - hash_combine(seed, *first); -} - - - - - hash_range is sensitive to the order of the elements - so it wouldn't be appropriate to use this with an unordered - container. - - This is an extension to TR1 - - Forward declared in - <boost/functional/hash_fwd.hpp> - - - This hash function is not intended for general use, and isn't - guaranteed to be equal during separate runs of a program - so - please don't use it for any persistent storage or communication. - - - - Only throws if hash_value(std::iterator_traits<It>::value_type) - throws. hash_range(std::size_t&, It, It) has basic exception safety as long as - hash_value(std::iterator_traits<It>::value_type) - has basic exception safety. - - - - - - - - - - - - Implementation of the hash function. - - - - std::size_t - bool - - - - std::size_t - char - - - - std::size_t - signed char - - - - std::size_t - unsigned char - - - - std::size_t - wchar_t - - - - std::size_t - char16_t - - - - std::size_t - char32_t - - - - std::size_t - short - - - - std::size_t - unsigned short - - - - std::size_t - int - - - - std::size_t - unsigned int - - - - std::size_t - long - - - - std::size_t - unsigned long - - - - std::size_t - long long - - - - std::size_t - unsigned long long - - - - std::size_t - float - - - - std::size_t - double - - - - std::size_t - long double - - - - - std::size_t - T* const& - - - - - std::size_t - T (&val)[N] - - - - - std::size_t - const T (&val)[N] - - - - - std::size_t - - std::basic_string<Ch, std::char_traits<Ch>, A> const& - - - - - - std::size_t - std::pair<A, B> const& - - - - - std::size_t - std::vector<T, A> const& - - - - - std::size_t - std::list<T, A> const& - - - - - std::size_t - std::deque<T, A> const& - - - - - std::size_t - std::set<K, C, A> const& - - - - - std::size_t - std::multiset<K, C, A> const& - - - - - std::size_t - std::map<K, T, C, A> const& - - - - - std::size_t - std::multimap<K, T, C, A> const& - - - - - std::size_t - std::complex<T> const& - - - - std::size_t - std::type_index - - - - - std::size_t - std::array<T, N> const& - - - - - std::size_t - std::tuple<T...> - - - - Generally shouldn't be called directly by users, instead they should use - boost::hash, boost::hash_range - or boost::hash_combine which - call hash_value without namespace qualification so that overloads - for custom types are found via ADL. - - - - This is an extension to TR1 - - This hash function is not intended for general use, and isn't - guaranteed to be equal during separate runs of a program - so - please don't use it for any persistent storage or communication. - - - - - Only throws if a user supplied version of - hash_value - throws for an element of a container, or - one of the types stored in a pair. - - - - - - - - Types - Returns - - - - - bool, - char, signed char, unsigned char, - wchar_t, char16_t, char32_t, - short, unsigned short, - int, unsigned int, long, unsigned long - - val - - - long long, unsigned long long - val when abs(val) <= std::numeric_limits<std::size_t>::max(). - - - float, double, long double - An unspecified value, except that equal arguments shall yield the same result. - - - T* - An unspecified value, except that equal arguments shall yield the same result. - - - - T val[N], - const T val[N] - - hash_range(val, val+N) - - - - std:basic_string<Ch, std::char_traits<Ch>, A>, - std::vector<T, A>, - std::list<T, A>, - std::deque<T, A>, - std::set<K, C, A>, - std::multiset<K, C, A>, - std::map<K, T, C, A>, - std::multimap<K, T, C, A>, - std::array<T, N> - - hash_range(val.begin(), val.end()) - - - std::pair<A, B> - size_t seed = 0; -hash_combine(seed, val.first); -hash_combine(seed, val.second); -return seed; - - - std::tuple<T...> - size_t seed = 0; -hash_combine(seed, get<0>(val)); -hash_combine(seed, get<1>(val)); -// .... -return seed; - - - - std::complex<T> - - When T is a built in type and val.imag() == 0, the result is equal to hash_value(val.real()). Otherwise an unspecified value, except that equal arguments shall yield the same result. - - - - std::type_index - - val.hash_code() - - - - - - - - -
-
- diff --git a/hash/doc/thanks.qbk b/hash/doc/thanks.qbk deleted file mode 100644 index fcc5108..0000000 --- a/hash/doc/thanks.qbk +++ /dev/null @@ -1,28 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[section:acknowledgements Acknowledgements] - -This library is based on the design by Peter Dimov. During the initial -development -Joaquín M López Muñoz made many useful suggestions and contributed fixes. - -The formal review was managed by Thorsten Ottosen, and the library reviewed by: -David Abrahams, Alberto Barbati, Topher Cooper, Caleb Epstein, Dave Harris, -Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter, -Rob Stewart and Pavel Vozenilek. Since then, further constructive criticism has -been made by Daniel Krügler, Alexander Nasonov and 沈慧峰. - -The implementation of the hash function for pointers is based on suggestions -made by Alberto Barbati and Dave Harris. Dave Harris also suggested an -important improvement to [funcref boost::hash_combine] that was taken up. - -Some useful improvements to the floating point hash algorithm were suggested -by Daniel Krügler. - -The original implementation came from Jeremy B. Maitin-Shepard's hash table -library, although this is a complete rewrite. - -[endsect] diff --git a/hash/doc/tutorial.qbk b/hash/doc/tutorial.qbk deleted file mode 100644 index 59067a7..0000000 --- a/hash/doc/tutorial.qbk +++ /dev/null @@ -1,212 +0,0 @@ - -[/ Copyright 2005-2008 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) ] - -[def __multi-index-short__ [@boost:/libs/multi_index/doc/index.html - Boost.MultiIndex]] - -[section:tutorial Tutorial] - -When using a hash index with __multi-index-short__, you don't need to do -anything to use [classref boost::hash] as it uses it by default. -To find out how to use a user-defined type, read the -[link hash.custom section on extending boost::hash for a custom data type]. - -If your standard library supplies its own implementation of the unordered -associative containers and you wish to use -[classref boost::hash], just use an extra template parameter: - - std::unordered_multiset > - set_of_ints; - - std::unordered_set, ``[classref boost::hash]`` > - set_of_pairs; - - std::unordered_map > map_int_to_string; - -To use [classref boost::hash] directly, create an instance and call it as a function: - - #include <``[headerref boost/functional/hash.hpp]``> - - int main() - { - ``[classref boost::hash]`` string_hash; - - std::size_t h = string_hash("Hash me"); - } - -For an example of generic use, here is a function to generate a vector -containing the hashes of the elements of a container: - - template - std::vector get_hashes(Container const& x) - { - std::vector hashes; - std::transform(x.begin(), x.end(), std::insert_iterator(hashes), - ``[classref boost::hash]``()); - - return hashes; - } - -[endsect] - -[section:custom Extending boost::hash for a custom data type] - -[classref boost::hash] is implemented by calling the function -[funcref boost::hash_value hash_value]. -The namespace isn't specified so that it can detect overloads via argument -dependant lookup. So if there is a free function `hash_value` in the same -namespace as a custom type, it will get called. - -If you have a structure `library::book`, where each `book` is uniquely -defined by it's member `id`: - - namespace library - { - struct book - { - int id; - std::string author; - std::string title; - - // .... - }; - - bool operator==(book const& a, book const& b) - { - return a.id == b.id; - } - } - -Then all you would need to do is write the function `library::hash_value`: - - namespace library - { - std::size_t hash_value(book const& b) - { - ``[classref boost::hash]`` hasher; - return hasher(b.id); - } - } - -And you can now use [classref boost::hash] with book: - - library::book knife(3458, "Zane Grey", "The Hash Knife Outfit"); - library::book dandelion(1354, "Paul J. Shanley", - "Hash & Dandelion Greens"); - - ``[classref boost::hash]`` book_hasher; - std::size_t knife_hash_value = book_hasher(knife); - - // If std::unordered_set is available: - std::unordered_set > books; - books.insert(knife); - books.insert(library::book(2443, "Lindgren, Torgny", "Hash")); - books.insert(library::book(1953, "Snyder, Bernadette M.", - "Heavenly Hash: A Tasty Mix of a Mother's Meditations")); - - assert(books.find(knife) != books.end()); - 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] -and -[@boost:/libs/functional/hash/examples/books.cpp /libs/functional/hash/examples/books.cpp]. - -[tip -When writing a hash function, first look at how the equality function works. -Objects that are equal must generate the same hash value. -When objects are not equal they should generate different hash values. -In this object equality was based just on the id so the hash function -only hashes the id. If it was based on the object's name and author -then the hash function should take them into account -(how to do this is discussed in the next section). -] - -[endsect] - -[section:combine Combining hash values] - -Say you have a point class, representing a two dimensional location: - - class point - { - int x; - int y; - public: - point() : x(0), y(0) {} - point(int x, int y) : x(x), y(y) {} - - bool operator==(point const& other) const - { - return x == other.x && y == other.y; - } - }; - -and you wish to use it as the key for an `unordered_map`. You need to -customise the hash for this structure. To do this we need to combine -the hash values for `x` and `y`. The function -[funcref boost::hash_combine] is supplied for this purpose: - - class point - { - ... - - friend std::size_t hash_value(point const& p) - { - std::size_t seed = 0; - ``[funcref boost::hash_combine]``(seed, p.x); - ``[funcref boost::hash_combine]``(seed, p.y); - - return seed; - } - - ... - }; - -Calls to hash_combine incrementally build the hash from the different members -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]. - -[note -When using [funcref boost::hash_combine] the order of the -calls matters. -''' - - std::size_t seed = 0; - boost::hash_combine(seed, 1); - boost::hash_combine(seed, 2); - -results in a different seed to: - - std::size_t seed = 0; - boost::hash_combine(seed, 2); - boost::hash_combine(seed, 1); - -''' -If you are calculating a hash value for data where the order of the data -doesn't matter in comparisons (e.g. a set) you will have to ensure that the -data is always supplied in the same order. -] - -To calculate the hash of an iterator range you can use [funcref boost::hash_range]: - - std::vector some_strings; - std::size_t hash = ``[funcref boost::hash_range]``(some_strings.begin(), some_strings.end()); - -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 `` -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]. - -[endsect] diff --git a/hash/examples/Jamfile.v2 b/hash/examples/Jamfile.v2 deleted file mode 100644 index 6291621..0000000 --- a/hash/examples/Jamfile.v2 +++ /dev/null @@ -1,9 +0,0 @@ - -# Copyright Daniel James 2005. Use, modification, and distribution are -# subject to 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) - -run books.cpp ; -run point.cpp ; -run portable.cpp ; -run template.cpp ; diff --git a/hash/examples/books.cpp b/hash/examples/books.cpp deleted file mode 100644 index 40feae3..0000000 --- a/hash/examples/books.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// 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 "./books.hpp" -#include -#include - -// If std::unordered_set was available: -//#include - -// This example illustrates how to use boost::hash with a custom hash function. -// For full details, see the tutorial. - -int main() -{ - library::book knife(3458, "Zane Grey", "The Hash Knife Outfit"); - library::book dandelion(1354, "Paul J. Shanley", "Hash & Dandelion Greens"); - - boost::hash book_hasher; - std::size_t knife_hash_value = book_hasher(knife); - (void)knife_hash_value; // suppress unused variable warning - - // If std::unordered_set was available: - // - //std::unordered_set > books; - //books.insert(knife); - //books.insert(library::book(2443, "Lindgren, Torgny", "Hash")); - //books.insert(library::book(1953, "Snyder, Bernadette M.", - // "Heavenly Hash: A Tasty Mix of a Mother's Meditations")); - - //assert(books.find(knife) != books.end()); - //assert(books.find(dandelion) == books.end()); - - return 0; -} - -namespace library -{ - bool operator==(book const& a, book const& b) - { - return a.id == b.id; - } - - std::size_t hash_value(book const& b) - { - boost::hash hasher; - return hasher(b.id); - } -} diff --git a/hash/examples/books.hpp b/hash/examples/books.hpp deleted file mode 100644 index ac87a9d..0000000 --- a/hash/examples/books.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -// 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) - -// This example illustrates how to use boost::hash with a custom hash function. -// The implementation is contained in books.cpp - -#include -#include - -namespace library -{ - struct book - { - int id; - std::string author; - std::string title; - - book(int i, std::string const& a, std::string const& t) - : id(i), author(a), title(t) {} - }; - - bool operator==(book const&, book const&); - std::size_t hash_value(book const&); -} diff --git a/hash/examples/point.cpp b/hash/examples/point.cpp deleted file mode 100644 index f3d30e1..0000000 --- a/hash/examples/point.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// Copyright 2005 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) - -// Force use of assert. -#if defined(NDEBUG) -#undef NDEBUG -#endif - -#include -#include - -// This example illustrates how to use boost::hash_combine to generate a hash -// value from the different members of a class. For full details see the hash -// tutorial. - -class point -{ - int x; - int y; -public: - point() : x(0), y(0) {} - point(int x, int y) : x(x), y(y) {} - - bool operator==(point const& other) const - { - return x == other.x && y == other.y; - } - - friend std::size_t hash_value(point const& p) - { - std::size_t seed = 0; - boost::hash_combine(seed, p.x); - boost::hash_combine(seed, p.y); - - return seed; - } -}; - -int main() -{ - boost::hash point_hasher; - - point p1(0, 0); - point p2(1, 2); - point p3(4, 1); - point p4 = p1; - - assert(point_hasher(p1) == point_hasher(p4)); - - // These tests could legally fail, but if they did it'd be a pretty bad - // hash function. - assert(point_hasher(p1) != point_hasher(p2)); - assert(point_hasher(p1) != point_hasher(p3)); - - return 0; -} - diff --git a/hash/examples/portable.cpp b/hash/examples/portable.cpp deleted file mode 100644 index 511133e..0000000 --- a/hash/examples/portable.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// 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) - -// Force use of assert. -#if defined(NDEBUG) -#undef NDEBUG -#endif - -#include -#include - -// This example illustrates how to customise boost::hash portably, so that -// it'll work on both compilers that don't implement argument dependent lookup -// and compilers that implement strict two-phase template instantiation. - -namespace foo -{ - template - class custom_type - { - T value; - public: - custom_type(T x) : value(x) {} - - std::size_t hash() const - { - boost::hash hasher; - return hasher(value); - } - }; -} - -#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -namespace boost -#else -namespace foo -#endif -{ - template - std::size_t hash_value(foo::custom_type x) - { - return x.hash(); - } -} - -int main() -{ - foo::custom_type x(1), y(2), z(1); - - boost::hash > hasher; - - assert(hasher(x) == hasher(x)); - assert(hasher(x) != hasher(y)); - assert(hasher(x) == hasher(z)); - - return 0; -} diff --git a/hash/examples/template.cpp b/hash/examples/template.cpp deleted file mode 100644 index d74f0a9..0000000 --- a/hash/examples/template.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// Copyright 2012 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 "template.hpp" -#include -#include - -int main() -{ - typedef my_pair pair; - boost::unordered_set pair_set; - pair_set.emplace(10, 0.5f); - - assert(pair_set.find(pair(10, 0.5f)) != pair_set.end()); - assert(pair_set.find(pair(10, 0.6f)) == pair_set.end()); -} diff --git a/hash/examples/template.hpp b/hash/examples/template.hpp deleted file mode 100644 index b630704..0000000 --- a/hash/examples/template.hpp +++ /dev/null @@ -1,36 +0,0 @@ - -// Copyright 2012 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) - -// This is an example of how to write a hash function for a template -// class. - -#include - -template -class my_pair -{ - A value1; - B value2; -public: - my_pair(A const& v1, B const& v2) - : value1(v1), value2(v2) - {} - - bool operator==(my_pair const& other) const - { - return value1 == other.value1 && - value2 == other.value2; - } - - friend std::size_t hash_value(my_pair const& p) - { - std::size_t seed = 0; - boost::hash_combine(seed, p.value1); - boost::hash_combine(seed, p.value2); - - return seed; - } -}; - diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 deleted file mode 100644 index 1da2da8..0000000 --- a/hash/test/Jamfile.v2 +++ /dev/null @@ -1,83 +0,0 @@ - -# Copyright 2005-2012 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) - -import testing ; - -project hash-tests - : requirements - all - intel:on - #intel:-strict-ansi - gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" - darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" - clang:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wsign-conversion -Wconversion -Wfloat-equal -Wshadow" - #msvc:on - #gcc:on - #darwin:on - ; - -test-suite functional/hash - : - [ compile check_float_funcs.cpp ] - [ run hash_fwd_test_1.cpp ] - [ run hash_fwd_test_2.cpp ] - [ run hash_number_test.cpp ] - [ run hash_enum_test.cpp ] - [ run hash_pointer_test.cpp ] - [ run hash_function_pointer_test.cpp ] - [ run hash_float_test.cpp ] - [ run hash_long_double_test.cpp ] - [ run hash_string_test.cpp ] - [ run hash_range_test.cpp ] - [ run hash_custom_test.cpp ] - [ run hash_global_namespace_test.cpp ] - [ run hash_friend_test.cpp ] - [ run hash_built_in_array_test.cpp ] - [ run hash_value_array_test.cpp ] - [ run hash_vector_test.cpp ] - [ run hash_list_test.cpp ] - [ run hash_deque_test.cpp ] - [ run hash_set_test.cpp ] - [ run hash_map_test.cpp ] - [ run hash_complex_test.cpp ] - [ run hash_type_index_test.cpp ] - [ run hash_std_array_test.cpp ] - [ run hash_std_tuple_test.cpp ] - [ run hash_std_smart_ptr_test.cpp ] - [ run link_test.cpp link_test_2.cpp ] - [ run link_ext_test.cpp link_no_ext_test.cpp ] - [ run extensions_hpp_test.cpp ] - [ compile-fail hash_no_ext_fail_test.cpp ] - [ compile-fail namespace_fail_test.cpp ] - [ run implicit_test.cpp ] - [ run hash_no_ext_macro_1.cpp ] - [ run hash_no_ext_macro_2.cpp ] - ; - -test-suite functional/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 ] - [ run hash_function_pointer_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_function_pointer_test ] - [ run hash_float_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_float_test ] - [ run hash_long_double_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_long_double_test ] - [ run hash_string_test.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_string_test ] - [ run link_test.cpp link_test_2.cpp : : : BOOST_HASH_NO_EXTENSIONS : no_ext_link_test ] - ; - -# 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 - : - [ run hash_float_test.cpp - : : : BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC - : hash_float_test_no_generic ] - [ run hash_long_double_test.cpp - : : : BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC - : hash_long_double_test_no_generic ] - ; -explicit functional/hash_no_generic_float ; - -build-project ../examples ; diff --git a/hash/test/check_float_funcs.cpp b/hash/test/check_float_funcs.cpp deleted file mode 100644 index 01d5168..0000000 --- a/hash/test/check_float_funcs.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// Copyright 2012 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 -#include -#include -#include - -namespace test -{ - template - struct check_return_type - { - template - static void equals(T2) - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - - template - static void equals_ref(T2&) - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - - template - static void convertible(T2) - { - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - } - }; -} - -int main() { - float f = 0; - double d = 0; - long double l = 0; - - test::check_return_type::equals(std::ldexp(f, 0)); - test::check_return_type::equals(std::ldexp(d, 0)); - test::check_return_type::equals(std::ldexp(l, 0)); - - int dummy = 0; - - test::check_return_type::equals(std::frexp(f, &dummy)); - test::check_return_type::equals(std::frexp(d, &dummy)); - test::check_return_type::equals(std::frexp(l, &dummy)); - -#if BOOST_HASH_USE_FPCLASSIFY - - int (*fpc1)(float) = std::fpclassify; - int (*fpc2)(double) = std::fpclassify; - int (*fpc3)(long double) = std::fpclassify; - -#endif -} diff --git a/hash/test/compile_time.hpp b/hash/test/compile_time.hpp deleted file mode 100644 index db6bc59..0000000 --- a/hash/test/compile_time.hpp +++ /dev/null @@ -1,18 +0,0 @@ - -// 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 -#include -#include - -template -void compile_time_tests(T*) -{ -#if !defined(_HAS_AUTO_PTR_ETC) || _HAS_AUTO_PTR_ETC - BOOST_STATIC_ASSERT((boost::is_base_and_derived< - std::unary_function, BOOST_HASH_TEST_NAMESPACE::hash >::value)); -#endif -} - diff --git a/hash/test/config.hpp b/hash/test/config.hpp deleted file mode 100644 index 53edf0a..0000000 --- a/hash/test/config.hpp +++ /dev/null @@ -1,21 +0,0 @@ - -// 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) - -#if defined(BOOST_HASH_TEST_STD) -# define BOOST_HASH_TEST_STD_INCLUDES -# define BOOST_HASH_TEST_NAMESPACE std -#else -# define BOOST_HASH_TEST_NAMESPACE boost -# if !defined(BOOST_HASH_NO_EXTENSIONS) -# define BOOST_HASH_TEST_EXTENSIONS -# endif -#endif - -#if defined(_WIN32_WCE) -// The standard windows mobile headers trigger this warning so I disable it -// before doing anything else. -#pragma warning(disable:4201) // nonstandard extension used : - // nameless struct/union -#endif diff --git a/hash/test/extensions_hpp_test.cpp b/hash/test/extensions_hpp_test.cpp deleted file mode 100644 index c27981a..0000000 --- a/hash/test/extensions_hpp_test.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// Copyright 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) - -// Check that boost/functional/hash/extensions.hpp works okay. -// -// It probably should be in boost/functional/hash/detail, but since it isn't it -// should work. - -#include "./config.hpp" - -#include - -int main() { - int x[2] = { 2, 3 }; - boost::hash hf; - hf(x); -} diff --git a/hash/test/hash_built_in_array_test.cpp b/hash/test/hash_built_in_array_test.cpp deleted file mode 100644 index e2dfe99..0000000 --- a/hash/test/hash_built_in_array_test.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -void array_int_test() -{ - const int length1 = 25; - int array1[25] = { - 26, -43, 32, 65, 45, - 12, 67, 32, 12, 23, - 0, 0, 0, 0, 0, - 8, -12, 23, 65, 45, - -1, 93, -54, 987, 3 - }; - BOOST_HASH_TEST_NAMESPACE::hash hasher1; - - const int length2 = 1; - int array2[1] = {3}; - BOOST_HASH_TEST_NAMESPACE::hash hasher2; - - const int length3 = 2; - int array3[2] = {2, 3}; - BOOST_HASH_TEST_NAMESPACE::hash hasher3; - - BOOST_TEST(hasher1(array1) - == BOOST_HASH_TEST_NAMESPACE::hash_range(array1, array1 + length1)); - BOOST_TEST(hasher2(array2) - == BOOST_HASH_TEST_NAMESPACE::hash_range(array2, array2 + length2)); - BOOST_TEST(hasher3(array3) - == BOOST_HASH_TEST_NAMESPACE::hash_range(array3, array3 + length3)); -} - -void two_dimensional_array_test() -{ - int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}}; - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - std::size_t seed1 = 0; - for(int i = 0; i < 3; ++i) - { - std::size_t seed2 = 0; - for(int j = 0; j < 2; ++j) - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, array[i][j]); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, seed2); - } - - BOOST_TEST(hasher(array) == seed1); - BOOST_TEST(hasher(array) == BOOST_HASH_TEST_NAMESPACE::hash_range(array, array + 3)); -} - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - array_int_test(); - two_dimensional_array_test(); -#endif - return boost::report_errors(); -} diff --git a/hash/test/hash_complex_test.cpp b/hash/test/hash_complex_test.cpp deleted file mode 100644 index 88f3833..0000000 --- a/hash/test/hash_complex_test.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -// 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 "./config.hpp" - -#if !defined(BOOST_HASH_TEST_EXTENSIONS) - -int main() {} - -#else - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include - -#if defined(BOOST_MSVC) -#pragma warning(disable:4244) // conversion from 'unsigned long' to - // 'unsigned short', possible loss of data -#pragma warning(disable:4245) // conversion from 'int' to - // 'const unsigned short', - // signed/unsigned mismatch -#pragma warning(disable:4305) // truncation from 'double' to - // 'const std::complex::_Ty' -#pragma warning(disable:4309) // truncation of constant value -#pragma warning(disable:4512) // assignment operator could not be generated -#if BOOST_MSVC < 1400 -#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', - // possible loss of data -#endif -#endif - -#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -#include -#include -#include - -template -void generic_complex_tests(std::complex v) -{ - BOOST_HASH_TEST_NAMESPACE::hash > complex_hasher; - - BOOST_TEST(complex_hasher(v) == complex_hasher(v)); - - BOOST_HASH_TEST_NAMESPACE::hash real_hasher; - T real = v.real(); - T imag = v.imag(); - - BOOST_TEST(real_hasher(real) == complex_hasher(std::complex(real))); - - if(imag != 0 && real_hasher(real) == complex_hasher(v)) { - std::ostringstream os; - os<<"real_hasher("< -void complex_float_tests(Float*) -{ - typedef std::complex complex; - generic_complex_tests(complex(0,0)); - generic_complex_tests(complex(0.5,0)); - generic_complex_tests(complex(25,0)); - generic_complex_tests(complex(25,0)); - generic_complex_tests(complex(static_cast(-67.5324535),static_cast(56.23578678))); -} - -template -void complex_integral_tests(Integer*) -{ - typedef std::complex complex; - generic_complex_tests(complex(0,0)); - generic_complex_tests(complex(15342,124)); - generic_complex_tests(complex(25,54356)); - generic_complex_tests(complex(5325,2346)); - generic_complex_tests(complex(Integer(-243897),Integer(-49923874))); - generic_complex_tests(complex(Integer(-543),Integer(763))); -} - -int main() -{ - // I've comments out the short and unsigned short tests - // as they cause warnings and don't really test - // anything that the other tests already deal with. - - complex_float_tests((float*) 0); - complex_float_tests((double*) 0); - complex_float_tests((long double*) 0); - //complex_integral_tests((short*) 0); - complex_integral_tests((int*) 0); - complex_integral_tests((long*) 0); - //complex_integral_tests((unsigned short*) 0); - complex_integral_tests((unsigned int*) 0); - complex_integral_tests((unsigned long*) 0); - - return boost::report_errors(); -} - -#endif // BOOST_HASH_TEST_EXTENSIONS diff --git a/hash/test/hash_custom_test.cpp b/hash/test/hash_custom_test.cpp deleted file mode 100644 index 4f125ab..0000000 --- a/hash/test/hash_custom_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -// 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 "./config.hpp" -#include -#include - -namespace test -{ - struct custom - { - int value_; - - std::size_t hash() const - { - return static_cast(value_ * 10); - } - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - friend std::size_t hash_value(custom const& x ) - { - return x.hash(); - } -#endif - - custom(int x) : value_(x) {} - }; -} - -#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace boost -{ - std::size_t hash_value(test::custom x) - { - return x.hash(); - } -} -#endif - -#include "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include -#include -#include - -void custom_tests() -{ - BOOST_HASH_TEST_NAMESPACE::hash custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); - test::custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); - - { - using namespace BOOST_HASH_TEST_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); - } - - std::vector custom_vector; - custom_vector.push_back(5); - custom_vector.push_back(25); - custom_vector.push_back(35); - - std::size_t seed = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(5)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(25)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(35)); - - std::size_t seed2 = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - - BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( - custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); -} - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - custom_tests(); -#endif - return boost::report_errors(); -} diff --git a/hash/test/hash_deque_test.cpp b/hash/test/hash_deque_test.cpp deleted file mode 100644 index 4d7f447..0000000 --- a/hash/test/hash_deque_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include - -using std::deque; -#define CONTAINER_TYPE deque -#include "./hash_sequence_test.hpp" - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - deque_tests::deque_hash_integer_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_enum_test.cpp b/hash/test/hash_enum_test.cpp deleted file mode 100644 index 2872b43..0000000 --- a/hash/test/hash_enum_test.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// Copyright 2012 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include "./compile_time.hpp" - -namespace test { - enum enum_override { enum_override1, enum_override2 }; - std::size_t hash_value(enum_override) { return 896532; } - - enum enum1 { enum1a }; - enum enum2 { enum2a, enum2b }; - enum enum3 { enum3a = 574, enum3b }; - enum enum4 { enum4a = -12574, enum4b }; -} - -int main() { - compile_time_tests((test::enum1*) 0); - compile_time_tests((test::enum2*) 0); - compile_time_tests((test::enum3*) 0); - compile_time_tests((test::enum4*) 0); - compile_time_tests((test::enum_override*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash hash1; - BOOST_HASH_TEST_NAMESPACE::hash hash2; - BOOST_HASH_TEST_NAMESPACE::hash hash3; - BOOST_HASH_TEST_NAMESPACE::hash hash4; - - BOOST_TEST(hash1(test::enum1a) == hash1(test::enum1a)); - - BOOST_TEST(hash2(test::enum2a) == hash2(test::enum2a)); - BOOST_TEST(hash2(test::enum2a) != hash2(test::enum2b)); - BOOST_TEST(hash2(test::enum2b) == hash2(test::enum2b)); - - BOOST_TEST(hash3(test::enum3a) == hash3(test::enum3a)); - BOOST_TEST(hash3(test::enum3a) != hash3(test::enum3b)); - BOOST_TEST(hash3(test::enum3b) == hash3(test::enum3b)); - - BOOST_TEST(hash4(test::enum4a) == hash4(test::enum4a)); - BOOST_TEST(hash4(test::enum4a) != hash4(test::enum4b)); - BOOST_TEST(hash4(test::enum4b) == hash4(test::enum4b)); - - BOOST_HASH_TEST_NAMESPACE::hash hash_override; - - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override1)); - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override2)); - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override1)); - - return boost::report_errors(); -} diff --git a/hash/test/hash_float_test.cpp b/hash/test/hash_float_test.cpp deleted file mode 100644 index 2490f8d..0000000 --- a/hash/test/hash_float_test.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// 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 "hash_float_test.hpp" - -int main() -{ - std::cerr<<"Compiler: "< -#else -# include -#endif - -#include - -#include -#include -#include -#include - -#include - -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4127) // conditional expression is constant -#pragma warning(disable:4723) // conditional expression is constant -#if BOOST_MSVC < 1400 -#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', - // possible loss of data -#endif -#endif - -#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -char const* float_type(float*) { return "float"; } -char const* float_type(double*) { return "double"; } -char const* float_type(long double*) { return "long double"; } - -template -void float_tests(char const* name, T* = 0) -{ - std::cerr - << "\n" - << "Testing " BOOST_STRINGIZE(BOOST_HASH_TEST_NAMESPACE) "::hash<" - << name - << ">\n" - << "\n" - << "boost::hash_detail::limits::digits = " - << boost::hash_detail::limits::digits<< "\n" - << "boost::hash_detail::limits::digits = " - << boost::hash_detail::limits::digits<< "\n" - << "boost::hash_detail::limits::digits = " - << boost::hash_detail::limits::digits - << "\n" - << "\n" - << "boost::hash_detail::call_ldexp::float_type = " - << float_type(static_cast::float_type*>(0)) - << "\n" - << "boost::hash_detail::call_frexp::float_type = " - << float_type(static_cast::float_type*>(0)) - << "\n" - << "boost::hash_detail::select_hash_type::type = " - << float_type(static_cast::type*>(0)) - << "\n" - << "\n" - ; - - BOOST_HASH_TEST_NAMESPACE::hash x1; - - T zero = 0; - T minus_zero = (T) -1 * zero; - - BOOST_TEST(zero == minus_zero); - BOOST_TEST(x1(zero) == x1(minus_zero)); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(zero) == BOOST_HASH_TEST_NAMESPACE::hash_value(zero)); - BOOST_TEST(x1(minus_zero) == BOOST_HASH_TEST_NAMESPACE::hash_value(minus_zero)); -#endif - - BOOST_TEST(x1(zero) != x1(0.5)); - BOOST_TEST(x1(minus_zero) != x1(0.5)); - BOOST_TEST(x1(0.5) != x1(-0.5)); - BOOST_TEST(x1(1) != x1(-1)); - - using namespace std; - -// Doing anything with infinity causes borland to crash. -#if defined(__BORLANDC__) - std::cerr - << "Not running infinity checks on Borland, as it causes it to crash." - "\n"; -#else - if(boost::hash_detail::limits::has_infinity) { - T infinity = -log(zero); - T infinity2 = (T) 1. / zero; - T infinity3 = (T) -1. / minus_zero; - T infinity4 = boost::hash_detail::limits::infinity(); - - T minus_infinity = log(zero); - T minus_infinity2 = (T) -1. / zero; - T minus_infinity3 = (T) 1. / minus_zero; - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(infinity) == BOOST_HASH_TEST_NAMESPACE::hash_value(infinity)); - BOOST_TEST(x1(minus_infinity) - == BOOST_HASH_TEST_NAMESPACE::hash_value(minus_infinity)); -#endif - - if(infinity == infinity2) - BOOST_TEST(x1(infinity) == x1(infinity2)); - if(infinity == infinity3) - BOOST_TEST(x1(infinity) == x1(infinity3)); - if(infinity == infinity4) - BOOST_TEST(x1(infinity) == x1(infinity4)); - - if(minus_infinity == minus_infinity2) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity2)); - if(minus_infinity == minus_infinity3) - BOOST_TEST(x1(minus_infinity) == x1(minus_infinity3)); - - BOOST_TEST(infinity != minus_infinity); - - if(x1(infinity) == x1(minus_infinity)) { - std::cerr<<"x1(infinity) == x1(-infinity) == "<::has_denorm) { - if(x1(boost::hash_detail::limits::denorm_min()) == x1(infinity)) - { - std::cerr - << "x1(denorm_min) == x1(infinity) == " - << x1(infinity) - << "\n"; - } - - if(x1(boost::hash_detail::limits::denorm_min()) == - x1(minus_infinity)) - { - std::cerr - << "x1(denorm_min) == x1(-infinity) == " - << x1(minus_infinity) - << "\n"; - } - } - - if(boost::hash_detail::limits::has_quiet_NaN) { - if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(infinity)) - { - std::cerr - << "x1(quiet_NaN) == x1(infinity) == " - << x1(infinity) - << "\n"; - } - - if(x1(boost::hash_detail::limits::quiet_NaN()) == - x1(minus_infinity)) - { - std::cerr - << "x1(quiet_NaN) == x1(-infinity) == " - << x1(minus_infinity) - << "\n"; - } - } - } -#endif - - T max = (boost::hash_detail::limits::max)(); - T half_max = max / 2; - T quarter_max = max / 4; - T three_quarter_max = max - quarter_max; - - // Check the limits::max is in range. - BOOST_TEST(max != half_max); - BOOST_TEST(max != quarter_max); - BOOST_TEST(max != three_quarter_max); - BOOST_TEST(half_max != quarter_max); - BOOST_TEST(half_max != three_quarter_max); - BOOST_TEST(quarter_max != three_quarter_max); - - BOOST_TEST(max != -max); - BOOST_TEST(half_max != -half_max); - BOOST_TEST(quarter_max != -quarter_max); - BOOST_TEST(three_quarter_max != -three_quarter_max); - - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(max) == BOOST_HASH_TEST_NAMESPACE::hash_value(max)); - BOOST_TEST(x1(half_max) == BOOST_HASH_TEST_NAMESPACE::hash_value(half_max)); - BOOST_TEST(x1(quarter_max) == BOOST_HASH_TEST_NAMESPACE::hash_value(quarter_max)); - BOOST_TEST(x1(three_quarter_max) == - BOOST_HASH_TEST_NAMESPACE::hash_value(three_quarter_max)); -#endif - - // The '!=' tests could legitimately fail, but with my hash it indicates a - // bug. - BOOST_TEST(x1(max) == x1(max)); - BOOST_TEST(x1(max) != x1(quarter_max)); - BOOST_TEST(x1(max) != x1(half_max)); - BOOST_TEST(x1(max) != x1(three_quarter_max)); - BOOST_TEST(x1(quarter_max) == x1(quarter_max)); - BOOST_TEST(x1(quarter_max) != x1(half_max)); - BOOST_TEST(x1(quarter_max) != x1(three_quarter_max)); - BOOST_TEST(x1(half_max) == x1(half_max)); - BOOST_TEST(x1(half_max) != x1(three_quarter_max)); - BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max)); - - BOOST_TEST(x1(max) != x1(-max)); - BOOST_TEST(x1(half_max) != x1(-half_max)); - BOOST_TEST(x1(quarter_max) != x1(-quarter_max)); - BOOST_TEST(x1(three_quarter_max) != x1(-three_quarter_max)); - - -// Intel with gcc stdlib sometimes segfaults on calls to asin and acos. -#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \ - defined(__ICC) || defined(__ECC)) && \ - (defined(__GLIBCPP__) || defined(__GLIBCXX__))) - T v1 = asin((T) 1); - T v2 = acos((T) 0); - if(v1 == v2) - BOOST_TEST(x1(v1) == x1(v2)); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(v1) == BOOST_HASH_TEST_NAMESPACE::hash_value(v1)); - BOOST_TEST(x1(v2) == BOOST_HASH_TEST_NAMESPACE::hash_value(v2)); -#endif - -#endif - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(boost::hash_detail::limits::epsilon()) == - BOOST_HASH_TEST_NAMESPACE::hash_value( - boost::hash_detail::limits::epsilon())); -#endif - - BOOST_TEST(boost::hash_detail::limits::epsilon() != (T) 0); - if(x1(boost::hash_detail::limits::epsilon()) == x1((T) 0)) - std::cerr<<"x1(epsilon) == x1(0) == "<::epsilon() != (T) 0); - if(x1(-boost::hash_detail::limits::epsilon()) == x1((T) 0)) - std::cerr<<"x1(-epsilon) == x1(0) == "<::epsilon() != (T) 1); - if(x1((T) 1 + boost::hash_detail::limits::epsilon()) == x1((T) 1)) - std::cerr<<"x1(1 + epsilon) == x1(1) == "<::epsilon() != (T) 1); - if(x1((T) 1 - boost::hash_detail::limits::epsilon()) == x1((T) 1)) - std::cerr<<"x1(1 - epsilon) == x1(1) == "<::epsilon() != (T) -1); - if(x1((T) -1 + boost::hash_detail::limits::epsilon()) == x1((T) -1)) - std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<::epsilon() != (T) -1); - if(x1((T) -1 - boost::hash_detail::limits::epsilon()) == x1((T) -1)) - std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<::has_denorm) { - if(x1(boost::hash_detail::limits::denorm_min()) == x1(zero)) { - std::cerr<<"x1(denorm_min) == x1(zero) == "<::denorm_min()) != - BOOST_HASH_TEST_NAMESPACE::hash_value( - boost::hash_detail::limits::denorm_min())) - { - std::cerr - << "x1(boost::hash_detail::limits::denorm_min()) = " - << x1(boost::hash_detail::limits::denorm_min()) - << "\nhash_value(boost::hash_detail::limits::denorm_min())" - " = " - << BOOST_HASH_TEST_NAMESPACE::hash_value( - boost::hash_detail::limits::denorm_min()) - << "\nx1(0) = " - << x1(0) - << "\n"; - } -#endif - } - -// NaN also causes borland to crash. -#if !defined(__BORLANDC__) && defined(BOOST_HASH_TEST_EXTENSIONS) - if(boost::hash_detail::limits::has_quiet_NaN) { - if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(1.0)) { - std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<::quiet_NaN()) == - BOOST_HASH_TEST_NAMESPACE::hash_value( - boost::hash_detail::limits::quiet_NaN())); - } -#endif -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif diff --git a/hash/test/hash_friend_test.cpp b/hash/test/hash_friend_test.cpp deleted file mode 100644 index 4b75f8a..0000000 --- a/hash/test/hash_friend_test.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -#include -#include - -namespace test -{ - template - struct custom - { - int value_; - - std::size_t hash() const - { - return static_cast(value_ * 10); - } - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - friend std::size_t hash_value(custom const& x) - { - return x.hash(); - } -#endif - - custom(int x) : value_(x) {} - }; -} - -#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace boost -{ - template - std::size_t hash_value(test::custom x) - { - return x.hash(); - } -} -#endif - -#include "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include -#include -#include - -void custom_tests() -{ - BOOST_HASH_TEST_NAMESPACE::hash > custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); - test::custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); - - { - using namespace BOOST_HASH_TEST_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); - } - - std::vector > custom_vector; - custom_vector.push_back(5); - custom_vector.push_back(25); - custom_vector.push_back(35); - - std::size_t seed = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(5)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(25)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(35)); - - std::size_t seed2 = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - - BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( - custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); -} - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - custom_tests(); -#endif - return boost::report_errors(); -} diff --git a/hash/test/hash_function_pointer_test.cpp b/hash/test/hash_function_pointer_test.cpp deleted file mode 100644 index 50fedf7..0000000 --- a/hash/test/hash_function_pointer_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include "./compile_time.hpp" - -void void_func1() { static int x = 1; ++x; } -void void_func2() { static int x = 2; --x; } -int int_func1(int) { return 0; } -int int_func2(int) { return 1; } - -void function_pointer_tests() -{ - compile_time_tests((void(**)()) 0); - compile_time_tests((int(**)(int)) 0); - - BOOST_HASH_TEST_NAMESPACE::hash hasher_void; - BOOST_HASH_TEST_NAMESPACE::hash hasher_int; - - BOOST_TEST(&void_func1 != &void_func2); - BOOST_TEST(&int_func1 != &int_func2); - - BOOST_TEST(hasher_void(0) == hasher_void(0)); - BOOST_TEST(hasher_void(&void_func1) == hasher_void(&void_func1)); - BOOST_TEST(hasher_void(&void_func1) != hasher_void(&void_func2)); - BOOST_TEST(hasher_void(&void_func1) != hasher_void(0)); - BOOST_TEST(hasher_int(0) == hasher_int(0)); - BOOST_TEST(hasher_int(&int_func1) == hasher_int(&int_func1)); - BOOST_TEST(hasher_int(&int_func1) != hasher_int(&int_func2)); - BOOST_TEST(hasher_int(&int_func1) != hasher_int(0)); -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(hasher_void(&void_func1) - == BOOST_HASH_TEST_NAMESPACE::hash_value(&void_func1)); - BOOST_TEST(hasher_int(&int_func1) - == BOOST_HASH_TEST_NAMESPACE::hash_value(&int_func1)); - - // This isn't specified in Peter's proposal: - BOOST_TEST(hasher_void(0) == 0); -#endif -} - -int main() -{ - function_pointer_tests(); - - return boost::report_errors(); -} diff --git a/hash/test/hash_fwd_test.hpp b/hash/test/hash_fwd_test.hpp deleted file mode 100644 index d3c8186..0000000 --- a/hash/test/hash_fwd_test.hpp +++ /dev/null @@ -1,104 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) -#include - -#include -#include -#include - -namespace test { - - template - struct test_type1 - { - T value; - test_type1(T const& x) : value(x) {} - }; - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - template - std::size_t hash_value(test_type1 const& x) - { - BOOST_HASH_TEST_NAMESPACE::hash hasher; - return hasher(x.value); - } -#endif - - template - struct test_type2 - { - T value1, value2; - test_type2(T const& x, T const& y) : value1(x), value2(y) {} - }; - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - template - std::size_t hash_value(test_type2 const& x) - { - std::size_t seed = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2); - return seed; - } -#endif - - template - struct test_type3 - { - std::vector values; - test_type3(typename std::vector::iterator x, - typename std::vector::iterator y) : values(x, y) {} - }; - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - template - std::size_t hash_value(test_type3 const& x) - { - std::size_t seed = - BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); - return seed; - } -#endif - -} - -#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - -namespace boost -{ - template - std::size_t hash_value(test::test_type1 const& x) - { - BOOST_HASH_TEST_NAMESPACE::hash hasher; - return hasher(x.value); - } - - template - std::size_t hash_value(test::test_type2 const& x) - { - std::size_t seed = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2); - return seed; - } - - template - std::size_t hash_value(test::test_type3 const& x) - { - std::size_t seed = - BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); - return seed; - } -} - -#endif - -#endif diff --git a/hash/test/hash_fwd_test_1.cpp b/hash/test/hash_fwd_test_1.cpp deleted file mode 100644 index 68fdde2..0000000 --- a/hash/test/hash_fwd_test_1.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -// Copyright 2006-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) - -// This checks that template code implemented using hash_fwd will work. - -#include "./config.hpp" - -#include "./hash_fwd_test.hpp" - -#include - -#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) - -#include -#include - -void fwd_test1() -{ - test::test_type1 x(5); - test::test_type1 y("Test"); - - BOOST_HASH_TEST_NAMESPACE::hash hasher_int; - BOOST_HASH_TEST_NAMESPACE::hash hasher_string; - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; - - BOOST_TEST(hasher_int(5) == hasher_test_int(x)); - BOOST_TEST(hasher_string("Test") == hasher_test_string(y)); -} - -void fwd_test2() -{ - test::test_type2 x(5, 10); - test::test_type2 y("Test1", "Test2"); - - std::size_t seed1 = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, 5); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, 10); - - std::size_t seed2 = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, std::string("Test1")); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, std::string("Test2")); - - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; - - BOOST_TEST(seed1 == hasher_test_int(x)); - BOOST_TEST(seed2 == hasher_test_string(y)); -} - -void fwd_test3() -{ - std::vector values1; - values1.push_back(10); - values1.push_back(15); - values1.push_back(20); - values1.push_back(3); - - std::vector values2; - values2.push_back("Chico"); - values2.push_back("Groucho"); - values2.push_back("Harpo"); - values2.push_back("Gummo"); - values2.push_back("Zeppo"); - - test::test_type3 x(values1.begin(), values1.end()); - test::test_type3 y(values2.begin(), values2.end()); - - std::size_t seed1 = - BOOST_HASH_TEST_NAMESPACE::hash_range(values1.begin(), values1.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed1, values1.begin(), values1.end()); - - std::size_t seed2 = - BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed2, values2.begin(), values2.end()); - - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; - BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; - - BOOST_TEST(seed1 == hasher_test_int(x)); - BOOST_TEST(seed2 == hasher_test_string(y)); -} - -#endif - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - fwd_test1(); - fwd_test2(); - fwd_test3(); -#endif - return boost::report_errors(); -} diff --git a/hash/test/hash_fwd_test_2.cpp b/hash/test/hash_fwd_test_2.cpp deleted file mode 100644 index d4c1a32..0000000 --- a/hash/test/hash_fwd_test_2.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// Copyright 2006-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) - -// This test just makes sure a header which uses hash_fwd can compile without -// the main hash headers. - -#include "./config.hpp" - -#if !defined(BOOST_HASH_TEST_EXTENSIONS) || defined(BOOST_HASH_TEST_STD_INCLUDES) - -int main() {} - -#else - -#include "./hash_fwd_test.hpp" -#include - -template void unused(T const&) {} - -void fwd_test() -{ - test::test_type1 x1(3); - test::test_type1 y1("Black"); - test::test_type2 x2(25, 16); - test::test_type2 y2("White", "Green"); - - std::vector empty; - std::vector empty2; - - test::test_type3 x3(empty.begin(), empty.end()); - test::test_type3 y3(empty2.begin(), empty2.end()); - - // Prevent gcc warnings: - unused(x1); unused(x2); unused(x3); - unused(y1); unused(y2); unused(y3); -} - -int main() -{ - fwd_test(); - - return boost::report_errors(); -} - -#endif // defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) diff --git a/hash/test/hash_global_namespace_test.cpp b/hash/test/hash_global_namespace_test.cpp deleted file mode 100644 index 7fc7bf6..0000000 --- a/hash/test/hash_global_namespace_test.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -// Copyright 2006-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) - -// This test demonstrates an ADL bug in Borland 5.5 where ADL isn't performed -// in the global namespace. - -#include "./config.hpp" - -#include -#include - -struct custom -{ - int value_; - - std::size_t hash() const - { - return static_cast(value_ * 10); - } - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) - friend std::size_t hash_value(custom const& x ) - { - return x.hash(); - } -#endif - - custom(int x) : value_(x) {} -}; - -#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace boost -{ - std::size_t hash_value(custom x) - { - return x.hash(); - } -} -#endif - -#include "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include -#include -#include - -void custom_tests() -{ - BOOST_HASH_TEST_NAMESPACE::hash custom_hasher; - BOOST_TEST(custom_hasher(10) == 100u); - custom x(55); - BOOST_TEST(custom_hasher(x) == 550u); - - { - using namespace BOOST_HASH_TEST_NAMESPACE; - BOOST_TEST(custom_hasher(x) == hash_value(x)); - } - - std::vector custom_vector; - custom_vector.push_back(5); - custom_vector.push_back(25); - custom_vector.push_back(35); - - std::size_t seed = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(5)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(25)); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(35)); - - std::size_t seed2 = 0; - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); - BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - - BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( - custom_vector.begin(), custom_vector.end())); - BOOST_TEST(seed == seed2); -} - -#endif // BOOST_HASH_TEST_EXTENSIONS - - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - custom_tests(); -#endif - return boost::report_errors(); -} - diff --git a/hash/test/hash_list_test.cpp b/hash/test/hash_list_test.cpp deleted file mode 100644 index a0f9716..0000000 --- a/hash/test/hash_list_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include - -using std::list; -#define CONTAINER_TYPE list -#include "./hash_sequence_test.hpp" - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - list_tests::list_hash_integer_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_long_double_test.cpp b/hash/test/hash_long_double_test.cpp deleted file mode 100644 index 860a679..0000000 --- a/hash/test/hash_long_double_test.cpp +++ /dev/null @@ -1,17 +0,0 @@ - -// 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 "hash_float_test.hpp" - -int main() -{ - std::cerr<<"Compiler: "< -# else -# include -# endif -#endif - -#include - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -using std::map; -#define CONTAINER_TYPE map -#include "./hash_map_test.hpp" - -using std::multimap; -#define CONTAINER_TYPE multimap -#include "./hash_map_test.hpp" - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - map_tests::map_hash_integer_tests(); - multimap_tests::multimap_hash_integer_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_map_test.hpp b/hash/test/hash_map_test.hpp deleted file mode 100644 index 41bb2fa..0000000 --- a/hash/test/hash_map_test.hpp +++ /dev/null @@ -1,76 +0,0 @@ - -// 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) - -#if !defined(CONTAINER_TYPE) -#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) -{ - template - void integer_tests(T* = 0) - { - const int number_of_containers = 10; - T containers[number_of_containers]; - typedef BOOST_DEDUCED_TYPENAME T::value_type pair; - typedef BOOST_DEDUCED_TYPENAME T::key_type key; - typedef BOOST_DEDUCED_TYPENAME T::mapped_type value; - - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < i; ++j) - containers[i].insert(pair(key(0), value(0))); - } - - containers[6].insert(pair(key(1),value(0))); - containers[7].insert(pair(key(1),value(0))); - containers[7].insert(pair(key(1),value(0))); - containers[8].insert(pair(key(-1),value(1))); - containers[9].insert(pair(key(-1),value(3))); - containers[9].insert(pair(key(-1),value(3))); - - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) == - BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) - == BOOST_HASH_TEST_NAMESPACE::hash_range( - containers[i2].begin(), containers[i2].end())); - - for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( - (containers[i2] == containers[j2]) == - (hasher(containers[i2]) == hasher(containers[j2])) - ); - } - } - } - - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) - { - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - } -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#undef CONTAINER_TYPE -#endif diff --git a/hash/test/hash_no_ext_fail_test.cpp b/hash/test/hash_no_ext_fail_test.cpp deleted file mode 100644 index 6d1636e..0000000 --- a/hash/test/hash_no_ext_fail_test.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -// Simple test to make sure BOOST_HASH_NO_EXTENSIONS does disable extensions -// (or at least one of them). -#if !defined(BOOST_HASH_NO_EXTENSIONS) -# define BOOST_HASH_NO_EXTENSIONS -#endif - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -template void ignore(T const&) {} - -int main() -{ - BOOST_HASH_TEST_NAMESPACE::hash< int[10] > hasher; - ignore(hasher); - - return 0; -} diff --git a/hash/test/hash_no_ext_macro_1.cpp b/hash/test/hash_no_ext_macro_1.cpp deleted file mode 100644 index d69e5b5..0000000 --- a/hash/test/hash_no_ext_macro_1.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - -// Include header without BOOST_HASH_NO_EXTENSIONS defined -# if defined(BOOST_HASH_NO_EXTENSIONS) -# undef BOOST_HASH_NO_EXTENSIONS -# endif -# include - -// Include header with BOOST_HASH_NO_EXTENSIONS defined -# define BOOST_HASH_NO_EXTENSIONS -# include -#endif - -#include -#include - -int main() -{ -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::deque x; - - x.push_back(1); - x.push_back(2); - - BOOST_HASH_TEST_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_no_ext_macro_2.cpp b/hash/test/hash_no_ext_macro_2.cpp deleted file mode 100644 index fe548ee..0000000 --- a/hash/test/hash_no_ext_macro_2.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - -// Include header with BOOST_HASH_NO_EXTENSIONS defined -# if !defined(BOOST_HASH_NO_EXTENSIONS) -# define BOOST_HASH_NO_EXTENSIONS -# endif -# include - -// Include header without BOOST_HASH_NO_EXTENSIONS defined -# undef BOOST_HASH_NO_EXTENSIONS -# include -#endif - -#include -#include - -int main() -{ -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::map x; - - x.insert(std::map::value_type(53, -42)); - x.insert(std::map::value_type(14, -75)); - - BOOST_HASH_TEST_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp deleted file mode 100644 index 18756c3..0000000 --- a/hash/test/hash_number_test.cpp +++ /dev/null @@ -1,204 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include - -#include -#include -#include - -#include "./compile_time.hpp" - -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4127) // conditional expression is constant -#pragma warning(disable:4309) // truncation of constant value -#pragma warning(disable:4310) // cast truncates constant value -#endif - -#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -template -void numeric_extra_tests(typename - boost::enable_if_c::is_integer, - void*>::type = 0) -{ - typedef boost::hash_detail::limits limits; - - if(limits::is_signed || - limits::digits <= boost::hash_detail::limits::digits) - { - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5)); - } - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u)); -} - -template -void numeric_extra_tests(typename - boost::disable_if_c::is_integer, - void*>::type = 0) -{ -} - -template -void numeric_test(T*) -{ - compile_time_tests((T*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - T v1 = (T) -5; - BOOST_TEST(x1(v1) == x2(v1)); - BOOST_TEST(x1(T(-5)) == x2(T(-5))); - BOOST_TEST(x1(T(0)) == x2(T(0))); - BOOST_TEST(x1(T(10)) == x2(T(10))); - BOOST_TEST(x1(T(25)) == x2(T(25))); - BOOST_TEST(x1(T(5) - T(5)) == x2(T(0))); - BOOST_TEST(x1(T(6) + T(4)) == x2(T(10))); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(T(-5)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(-5))); - BOOST_TEST(x1(T(0)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(0))); - BOOST_TEST(x1(T(10)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(10))); - BOOST_TEST(x1(T(25)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(25))); - - numeric_extra_tests(); -#endif -} - -template -void limits_test(T*) -{ - typedef boost::hash_detail::limits limits; - - if(limits::is_specialized) - { - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - T min_value = (limits::min)(); - T max_value = (limits::max)(); - - BOOST_TEST(x1(min_value) == x2((limits::min)())); - BOOST_TEST(x1(max_value) == x2((limits::max)())); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(min_value) == BOOST_HASH_TEST_NAMESPACE::hash_value(min_value)); - BOOST_TEST(x1(max_value) == BOOST_HASH_TEST_NAMESPACE::hash_value(max_value)); - - if (limits::is_integer) - { - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(min_value) - == std::size_t(min_value)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(max_value) - == std::size_t(max_value)); - } -#endif - } -} - -template -void poor_quality_tests(T*) -{ - typedef boost::hash_detail::limits limits; - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - // A hash function can legally fail these tests, but it'll not be a good - // sign. - if(T(1) != T(-1)) - BOOST_TEST(x1(T(1)) != x2(T(-1))); - if(T(1) != T(2)) - BOOST_TEST(x1(T(1)) != x2(T(2))); - - // TODO: This test is useless for floating point numbers. - T max_number = static_cast((limits::max)()); - T max_minus_one = static_cast(max_number - 1); - if (max_number != max_minus_one) { - BOOST_TEST(x1(max_number) != x1(max_minus_one)); - } -} - -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)); - BOOST_TEST(x1(false) != x2(true)); -} - -#define NUMERIC_TEST(type, name) \ - std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \ - numeric_test((type*) 0); \ - limits_test((type*) 0); \ - poor_quality_tests((type*) 0); -#define NUMERIC_TEST_NO_LIMITS(type, name) \ - std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \ - numeric_test((type*) 0); \ - poor_quality_tests((type*) 0); - -int main() -{ - NUMERIC_TEST(char, char) - NUMERIC_TEST(signed char, schar) - NUMERIC_TEST(unsigned char, uchar) -#ifndef BOOST_NO_INTRINSIC_WCHAR_T - NUMERIC_TEST(wchar_t, wchar) -#endif -#ifndef BOOST_NO_CXX11_CHAR16_T - NUMERIC_TEST(char16_t, char16) -#endif -#ifndef BOOST_NO_CXX11_CHAR32_T - NUMERIC_TEST(char32_t, char32) -#endif - NUMERIC_TEST(short, short) - NUMERIC_TEST(unsigned short, ushort) - NUMERIC_TEST(int, int) - NUMERIC_TEST(unsigned int, uint) - NUMERIC_TEST(long, hash_long) - NUMERIC_TEST(unsigned long, ulong) - -#if !defined(BOOST_NO_LONG_LONG) - NUMERIC_TEST_NO_LIMITS(boost::long_long_type, long_long) - NUMERIC_TEST_NO_LIMITS(boost::ulong_long_type, ulong_long) -#endif - -#if defined(BOOST_HAS_INT128) - NUMERIC_TEST_NO_LIMITS(boost::int128_type, int128) - NUMERIC_TEST_NO_LIMITS(boost::uint128_type, uint128) -#endif - - NUMERIC_TEST(float, float) - NUMERIC_TEST(double, double) - - NUMERIC_TEST(std::size_t, size_t) - NUMERIC_TEST(std::ptrdiff_t, ptrdiff_t) - - bool_test(); - - return boost::report_errors(); -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif diff --git a/hash/test/hash_pointer_test.cpp b/hash/test/hash_pointer_test.cpp deleted file mode 100644 index 7cacaa8..0000000 --- a/hash/test/hash_pointer_test.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include -#include "./compile_time.hpp" - -void pointer_tests() -{ - compile_time_tests((int**) 0); - compile_time_tests((void**) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - int int1; - int int2; - - BOOST_TEST(x1(0) == x2(0)); - BOOST_TEST(x1(&int1) == x2(&int1)); - BOOST_TEST(x1(&int2) == x2(&int2)); -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(&int1) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int1)); - BOOST_TEST(x1(&int2) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int2)); - - // This isn't specified in Peter's proposal: - BOOST_TEST(x1(0) == 0); -#endif -} - -int main() -{ - pointer_tests(); - return boost::report_errors(); -} diff --git a/hash/test/hash_range_test.cpp b/hash/test/hash_range_test.cpp deleted file mode 100644 index a5bdbb6..0000000 --- a/hash/test/hash_range_test.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// 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 "./config.hpp" - -#if !defined(BOOST_HASH_TEST_EXTENSIONS) - -int main() {} - -#else - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include -#include - -void hash_range_tests() -{ - std::vector empty, values1, values2, values3, values4, values5; - values1.push_back(0); - values2.push_back(10); - values3.push_back(10); - values3.push_back(20); - values4.push_back(15); - values4.push_back(75); - values5.push_back(10); - values5.push_back(20); - values5.push_back(15); - values5.push_back(75); - values5.push_back(10); - values5.push_back(20); - - std::vector x; - - std::size_t x_seed = 0; - BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) - == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) - != BOOST_HASH_TEST_NAMESPACE::hash_range(values1.begin(), values1.end())); - - x.push_back(10); - BOOST_HASH_TEST_NAMESPACE::hash_combine(x_seed, 10); - BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) - != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()) - == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - - x.push_back(20); - BOOST_HASH_TEST_NAMESPACE::hash_combine(x_seed, 20); - BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) - != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()) - != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values3.begin(), values3.end()) - == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - - std::size_t seed = - BOOST_HASH_TEST_NAMESPACE::hash_range(values3.begin(), values3.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed, values4.begin(), values4.end()); - BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.begin(), x.end()); - BOOST_TEST(seed == - BOOST_HASH_TEST_NAMESPACE::hash_range(values5.begin(), values5.end())); -} - -int main() -{ - hash_range_tests(); - - return boost::report_errors(); -} - -#endif // TEST_EXTESNIONS diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp deleted file mode 100644 index 30083f9..0000000 --- a/hash/test/hash_sequence_test.hpp +++ /dev/null @@ -1,78 +0,0 @@ - -// 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) - -#if !defined(CONTAINER_TYPE) -#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) -{ - template - void integer_tests(T* = 0) - { - typedef typename T::value_type value_type; - - const int number_of_containers = 11; - T containers[number_of_containers]; - - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < i; ++j) - containers[i].push_back(0); - } - - containers[5].push_back(value_type(1)); - containers[6].push_back(value_type(1)); - containers[6].push_back(value_type(1)); - containers[7].push_back(value_type(-1)); - containers[8].push_back(value_type(-1)); - containers[8].push_back(value_type(-1)); - containers[9].push_back(value_type(1)); - containers[9].push_back(value_type(-1)); - containers[10].push_back(value_type(-1)); - containers[10].push_back(value_type(1)); - - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) == - BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) - == BOOST_HASH_TEST_NAMESPACE::hash_range( - containers[i2].begin(), containers[i2].end())); - - for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( - (containers[i2] == containers[j2]) == - (hasher(containers[i2]) == hasher(containers[j2])) - ); - } - } - } - - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) - { - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - } -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#undef CONTAINER_TYPE -#endif diff --git a/hash/test/hash_set_test.cpp b/hash/test/hash_set_test.cpp deleted file mode 100644 index 1cf9fef..0000000 --- a/hash/test/hash_set_test.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include - -using std::set; -#define CONTAINER_TYPE set -#include "./hash_set_test.hpp" - -using std::multiset; -#define CONTAINER_TYPE multiset -#include "./hash_set_test.hpp" - -#endif - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - set_tests::set_hash_integer_tests(); - multiset_tests::multiset_hash_integer_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp deleted file mode 100644 index 0a90330..0000000 --- a/hash/test/hash_set_test.hpp +++ /dev/null @@ -1,81 +0,0 @@ - -// 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) - -#if !defined(CONTAINER_TYPE) -#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) -{ - template - void integer_tests(T* = 0) - { - typedef typename T::value_type value_type; - - const int number_of_containers = 12; - T containers[number_of_containers]; - - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < i; ++j) - containers[i].insert(0); - } - - containers[6].insert(value_type(1)); - containers[7].insert(value_type(1)); - containers[7].insert(value_type(1)); - containers[8].insert(value_type(-1)); - containers[9].insert(value_type(-1)); - containers[9].insert(value_type(-1)); - containers[10].insert(value_type(-1)); - containers[10].insert(value_type(1)); - containers[11].insert(value_type(1)); - containers[11].insert(value_type(2)); - containers[11].insert(value_type(3)); - containers[11].insert(value_type(4)); - containers[11].insert(value_type(5)); - - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - for(int i2 = 0; i2 < number_of_containers; ++i2) { - BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) == - BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); - - BOOST_TEST(hasher(containers[i2]) - == BOOST_HASH_TEST_NAMESPACE::hash_range( - containers[i2].begin(), containers[i2].end())); - - for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { - BOOST_TEST( - (containers[i2] == containers[j2]) == - (hasher(containers[i2]) == hasher(containers[j2])) - ); - } - } - } - - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) - { - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - integer_tests((CONTAINER_TYPE*) 0); - } -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#undef CONTAINER_TYPE -#endif diff --git a/hash/test/hash_std_array_test.cpp b/hash/test/hash_std_array_test.cpp deleted file mode 100644 index 2b240a3..0000000 --- a/hash/test/hash_std_array_test.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -// Copyright 2012 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include -#include - -#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_ARRAY) -#define TEST_ARRAY -#include -#include -#endif - -#ifdef TEST_ARRAY - -template -void array_tests(T const& v) { - boost::hash hf; - for(typename T::const_iterator i = v.begin(); i != v.end(); ++i) { - for(typename T::const_iterator j = v.begin(); j != v.end(); ++j) { - if (i != j) - BOOST_TEST(hf(*i) != hf(*j)); - else - BOOST_TEST(hf(*i) == hf(*j)); - } - } -} - -void empty_array_test() { -/* - boost::hash > empty_array_hash; - std::array empty_array; - BOOST_TEST(empty_array_hash(empty_array) == boost::hash_value(empty_array)); -*/ -} - -void int_1_array_test() -{ - std::vector > arrays; - std::array val; - val[0] = 0; - arrays.push_back(val); - val[0] = 1; - arrays.push_back(val); - val[0] = 2; - arrays.push_back(val); - array_tests(arrays); -} - -void string_1_array_test() -{ - std::vector > arrays; - std::array val; - arrays.push_back(val); - val[0] = "one"; - arrays.push_back(val); - val[0] = "two"; - arrays.push_back(val); - array_tests(arrays); -} - -void string_3_array_test() -{ - std::vector > arrays; - std::array val; - arrays.push_back(val); - val[0] = "one"; - arrays.push_back(val); - val[0] = ""; val[1] = "one"; val[2] = ""; - arrays.push_back(val); - val[0] = ""; val[1] = ""; val[2] = "one"; - arrays.push_back(val); - val[0] = "one"; val[1] = "one"; val[2] = "one"; - arrays.push_back(val); - val[0] = "one"; val[1] = "two"; val[2] = "three"; - arrays.push_back(val); - array_tests(arrays); -} - -#endif // TEST_ARRAY - -int main() -{ -#ifdef TEST_ARRAY - empty_array_test(); - int_1_array_test(); - string_1_array_test(); - string_3_array_test(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_std_smart_ptr_test.cpp b/hash/test/hash_std_smart_ptr_test.cpp deleted file mode 100644 index feb09d9..0000000 --- a/hash/test/hash_std_smart_ptr_test.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -// Copyright 2012 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include "./compile_time.hpp" - -#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_SMART_PTR) -#define TEST_SMART_PTRS -#include -#endif - -#ifdef TEST_SMART_PTRS - -void shared_ptr_tests() -{ - std::shared_ptr x; - compile_time_tests(&x); - - BOOST_HASH_TEST_NAMESPACE::hash > x1; - BOOST_HASH_TEST_NAMESPACE::hash > x2; - - std::shared_ptr ptr1(new int(10)); - std::shared_ptr ptr2; - - BOOST_TEST(x1(x) == x2(ptr2)); - BOOST_TEST(x1(x) != x2(ptr1)); - ptr2.reset(new int(10)); - BOOST_TEST(x1(ptr1) == x2(ptr1)); - BOOST_TEST(x1(ptr1) != x2(ptr2)); - ptr2 = ptr1; - BOOST_TEST(x1(ptr1) == x2(ptr2)); -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); - BOOST_TEST(x1(ptr1) == BOOST_HASH_TEST_NAMESPACE::hash_value(ptr2)); -#endif -} - -void unique_ptr_tests() -{ - std::unique_ptr x; - compile_time_tests(&x); - - BOOST_HASH_TEST_NAMESPACE::hash > x1; - BOOST_HASH_TEST_NAMESPACE::hash > x2; - - std::unique_ptr ptr1(new int(10)); - std::unique_ptr ptr2; - - BOOST_TEST(x1(x) == x2(ptr2)); - BOOST_TEST(x1(x) != x2(ptr1)); - ptr2.reset(new int(10)); - BOOST_TEST(x1(ptr1) == x2(ptr1)); - BOOST_TEST(x1(ptr1) != x2(ptr2)); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - BOOST_TEST(x1(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); -#endif -} - -#endif - -int main() -{ -#ifdef TEST_SMART_PTRS - shared_ptr_tests(); - unique_ptr_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_std_tuple_test.cpp b/hash/test/hash_std_tuple_test.cpp deleted file mode 100644 index 97bea99..0000000 --- a/hash/test/hash_std_tuple_test.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// Copyright 2012 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include -#include - -#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_TUPLE) -#define TEST_TUPLE -#include -#include -#endif - -#ifdef TEST_TUPLE - -template -void tuple_tests(T const& v) { - boost::hash hf; - for(typename T::const_iterator i = v.begin(); i != v.end(); ++i) { - for(typename T::const_iterator j = v.begin(); j != v.end(); ++j) { - if (i != j) - BOOST_TEST(hf(*i) != hf(*j)); - else - BOOST_TEST(hf(*i) == hf(*j)); - } - } -} - -void empty_tuple_test() { - boost::hash > empty_tuple_hash; - std::tuple<> empty_tuple; - BOOST_TEST(empty_tuple_hash(empty_tuple) == boost::hash_value(empty_tuple)); -} - -void int_tuple_test() { - std::vector > int_tuples; - int_tuples.push_back(std::make_tuple(0)); - int_tuples.push_back(std::make_tuple(1)); - int_tuples.push_back(std::make_tuple(2)); - tuple_tests(int_tuples); -} - -void int_string_tuple_test() { - std::vector > int_string_tuples; - int_string_tuples.push_back(std::make_tuple(0, std::string("zero"))); - int_string_tuples.push_back(std::make_tuple(1, std::string("one"))); - int_string_tuples.push_back(std::make_tuple(2, std::string("two"))); - int_string_tuples.push_back(std::make_tuple(0, std::string("one"))); - int_string_tuples.push_back(std::make_tuple(1, std::string("zero"))); - int_string_tuples.push_back(std::make_tuple(0, std::string(""))); - int_string_tuples.push_back(std::make_tuple(1, std::string(""))); - tuple_tests(int_string_tuples); -} - -#endif // TEST_TUPLE - -int main() -{ -#ifdef TEST_TUPLE - empty_tuple_test(); - int_tuple_test(); - int_string_tuple_test(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/hash_string_test.cpp b/hash/test/hash_string_test.cpp deleted file mode 100644 index 7088d67..0000000 --- a/hash/test/hash_string_test.cpp +++ /dev/null @@ -1,147 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif - -#include -#include -#include "./compile_time.hpp" - -void string_tests() -{ - compile_time_tests((std::string*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - BOOST_TEST(x1("Hello") == x2(std::string("Hel") + "lo")); - BOOST_TEST(x1("") == x2(std::string())); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::string value1; - std::string value2("Hello"); - - BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); -#endif -} - -void string0_tests() -{ - std::string x1(1, '\0'); - std::string x2(2, '\0'); - std::string x3(3, '\0'); - std::string x4(10, '\0'); - - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - BOOST_TEST(hasher(x1) != hasher(x2)); - BOOST_TEST(hasher(x1) != hasher(x3)); - BOOST_TEST(hasher(x1) != hasher(x4)); - BOOST_TEST(hasher(x2) != hasher(x3)); - BOOST_TEST(hasher(x2) != hasher(x4)); - BOOST_TEST(hasher(x3) != hasher(x4)); -} - -#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) -void wstring_tests() -{ - compile_time_tests((std::wstring*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - BOOST_TEST(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo")); - BOOST_TEST(x1(L"") == x2(std::wstring())); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::wstring value1; - std::wstring value2(L"Hello"); - - BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); -#endif -} -#endif - -#if !defined(BOOST_NO_CXX11_CHAR16_T) -void u16string_tests() -{ - compile_time_tests((std::u16string*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - BOOST_TEST(x1(u"Hello") == x2(std::u16string(u"Hel") + u"lo")); - BOOST_TEST(x1(u"") == x2(std::u16string())); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::u16string value1; - std::u16string value2(u"Hello"); - - BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); -#endif -} -#endif - -#if !defined(BOOST_NO_CXX11_CHAR32_T) -void u32string_tests() -{ - compile_time_tests((std::u32string*) 0); - - BOOST_HASH_TEST_NAMESPACE::hash x1; - BOOST_HASH_TEST_NAMESPACE::hash x2; - - BOOST_TEST(x1(U"Hello") == x2(std::u32string(U"Hel") + U"lo")); - BOOST_TEST(x1(U"") == x2(std::u32string())); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - std::u32string value1; - std::u32string value2(U"Hello"); - - BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); - BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == - BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); -#endif -} -#endif - -int main() -{ - string_tests(); - string0_tests(); -#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - wstring_tests(); -#endif -#if !defined(BOOST_NO_CXX11_CHAR16_T) - u16string_tests(); -#endif -#if !defined(BOOST_NO_CXX11_CHAR32_T) - u32string_tests(); -#endif - return boost::report_errors(); -} diff --git a/hash/test/hash_type_index_test.cpp b/hash/test/hash_type_index_test.cpp deleted file mode 100644 index 3288a5b..0000000 --- a/hash/test/hash_type_index_test.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// Copyright 2011 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -#else -# include -#endif -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) - -#include - -void test_type_index() { - BOOST_HASH_TEST_NAMESPACE::hash hasher; - -#if defined(BOOST_NO_TYPEID) - std::cout<<"Unable to test std::type_index, as typeid isn't available" - < not available."< -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -void array_int_test() -{ - const int array1[25] = { - 26, -43, 32, 65, 45, - 12, 67, 32, 12, 23, - 0, 0, 0, 0, 0, - 8, -12, 23, 65, 45, - -1, 93, -54, 987, 3 - }; - BOOST_HASH_TEST_NAMESPACE::hash hasher1; - - int array2[1] = {3}; - BOOST_HASH_TEST_NAMESPACE::hash hasher2; - - int array3[2] = {2, 3}; - BOOST_HASH_TEST_NAMESPACE::hash hasher3; - - BOOST_TEST(hasher1(array1) == BOOST_HASH_TEST_NAMESPACE::hash_value(array1)); - BOOST_TEST(hasher2(array2) == BOOST_HASH_TEST_NAMESPACE::hash_value(array2)); - BOOST_TEST(hasher3(array3) == BOOST_HASH_TEST_NAMESPACE::hash_value(array3)); -} - -void two_dimensional_array_test() -{ - int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}}; - BOOST_HASH_TEST_NAMESPACE::hash hasher; - - BOOST_TEST(hasher(array) == BOOST_HASH_TEST_NAMESPACE::hash_value(array)); -} - -#endif - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - array_int_test(); - two_dimensional_array_test(); -#endif - - return boost::report_errors(); -} - diff --git a/hash/test/hash_vector_test.cpp b/hash/test/hash_vector_test.cpp deleted file mode 100644 index 6dcf3b0..0000000 --- a/hash/test/hash_vector_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// 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 "./config.hpp" - -#ifdef BOOST_HASH_TEST_EXTENSIONS -# ifdef BOOST_HASH_TEST_STD_INCLUDES -# include -# else -# include -# endif -#endif - -#include - -#ifdef BOOST_HASH_TEST_EXTENSIONS - -#include - -using std::vector; -#define CONTAINER_TYPE vector -#include "./hash_sequence_test.hpp" - -#endif // BOOST_HASH_TEST_EXTENSIONS - -int main() -{ -#ifdef BOOST_HASH_TEST_EXTENSIONS - vector_tests::vector_hash_integer_tests(); -#endif - - return boost::report_errors(); -} diff --git a/hash/test/implicit_test.cpp b/hash/test/implicit_test.cpp deleted file mode 100644 index e48bbcd..0000000 --- a/hash/test/implicit_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// Copyright 2010 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 - -namespace test -{ - struct base {}; - std::size_t hash_value(base const&) { return 0; } - - struct converts { operator base() const { return base(); } }; -} - -int main() { - boost::hash hash; - test::converts x; - - hash(x); -} diff --git a/hash/test/link_ext_test.cpp b/hash/test/link_ext_test.cpp deleted file mode 100644 index 74a4eb5..0000000 --- a/hash/test/link_ext_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// Copyright 2006-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 "./config.hpp" - -#define BOOST_HASH_TEST_NAMESPACE boost -#include -#include -#include - -int f(std::size_t hash1, int* x1) { - - // Check that BOOST_HASH_TEST_NAMESPACE::hash works in both files. - BOOST_HASH_TEST_NAMESPACE::hash ptr_hasher; - BOOST_TEST(hash1 == ptr_hasher(x1)); - -#if defined(BOOST_HASH_TEST_EXTENSIONS) - - // Check that std::vector is avaiable in this file. - std::vector x; - x.push_back(static_cast(*x1)); - BOOST_HASH_TEST_NAMESPACE::hash > vector_hasher; - return vector_hasher(x) != BOOST_HASH_TEST_NAMESPACE::hash_value(x); - -#else - - return 0; - -#endif -} - diff --git a/hash/test/link_no_ext_test.cpp b/hash/test/link_no_ext_test.cpp deleted file mode 100644 index 75cd47d..0000000 --- a/hash/test/link_no_ext_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// 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 "./config.hpp" - -#define BOOST_HASH_TEST_NAMESPACE boost -#define BOOST_HASH_NO_EXTENSIONS -#include -#include - -extern int f(std::size_t, int*); - -int main() { - BOOST_HASH_TEST_NAMESPACE::hash ptr_hasher; - int x = 55; - BOOST_TEST(!f(ptr_hasher(&x), &x)); - return boost::report_errors(); -} diff --git a/hash/test/link_test.cpp b/hash/test/link_test.cpp deleted file mode 100644 index bdae262..0000000 --- a/hash/test/link_test.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// 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 "./config.hpp" - -#include - -extern int f(); -int main() { return f(); } diff --git a/hash/test/link_test_2.cpp b/hash/test/link_test_2.cpp deleted file mode 100644 index 1beffc8..0000000 --- a/hash/test/link_test_2.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -// 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 "./config.hpp" - -#include - -int f() { return 0; } diff --git a/hash/test/namespace_fail_test.cpp b/hash/test/namespace_fail_test.cpp deleted file mode 100644 index 1db9fc6..0000000 --- a/hash/test/namespace_fail_test.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// Copyright 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) - -// Check that I haven't inadvertantly pulled namespace std into the global -// namespace. - -#include "./config.hpp" - -#include -#include - -typedef list foo; - -int main() {} diff --git a/include/boost/functional/factory.hpp b/include/boost/functional/factory.hpp index 67fee71..92f67d9 100644 --- a/include/boost/functional/factory.hpp +++ b/include/boost/functional/factory.hpp @@ -12,6 +12,7 @@ # include # include # include +# include # include # include @@ -74,15 +75,26 @@ namespace boost template< class Pointer, class Allocator, factory_alloc_propagation AP > class factory +#if defined(BOOST_NO_CXX11_ALLOCATOR) : private Allocator::template rebind< typename boost::pointee< typename boost::remove_cv::type >::type >::other +#else + : private std::allocator_traits::template rebind_alloc< + typename boost::pointee< typename boost::remove_cv::type >::type > +#endif { public: typedef typename boost::remove_cv::type result_type; typedef typename boost::pointee::type value_type; +#if defined(BOOST_NO_CXX11_ALLOCATOR) typedef typename Allocator::template rebind::other allocator_type; +#else + typedef typename std::allocator_traits::template rebind_alloc + allocator_type; + typedef std::allocator_traits allocator_traits; +#endif explicit factory(allocator_type const & a = allocator_type()) : allocator_type(a) @@ -105,9 +117,16 @@ namespace boost void operator()(value_type* ptr) const { - if (!! ptr) ptr->~value_type(); - const_cast(static_cast( - this))->deallocate(ptr,1); + if (!! ptr) { +#if defined(BOOST_NO_CXX11_ALLOCATOR) + ptr->~value_type(); + const_cast(static_cast( + this))->deallocate(ptr,1); +#else + allocator_traits::destroy(this->get_allocator(), ptr); + allocator_traits::deallocate(this->get_allocator(),ptr,1); +#endif + } } }; @@ -162,14 +181,30 @@ namespace boost # endif inline result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const { +#if defined(BOOST_NO_CXX11_ALLOCATOR) value_type* memory = this->get_allocator().allocate(1); +#else + value_type* memory = allocator_traits::allocate(this->get_allocator(), 1); +#endif try - { - return make_pointer( - new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)), - boost::non_type() ); + { +#if defined(BOOST_NO_CXX11_ALLOCATOR) + new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)); +#else + allocator_traits::construct(this->get_allocator(), memory + BOOST_PP_ENUM_TRAILING_PARAMS(N,a)); +#endif } - catch (...) { this->get_allocator().deallocate(memory,1); throw; } + catch (...) { +#if defined(BOOST_NO_CXX11_ALLOCATOR) + this->get_allocator().deallocate(memory,1); +#else + allocator_traits::deallocate(this->get_allocator(), memory, 1); +#endif + throw; + } + + return make_pointer(memory, boost::non_type()); } # endif # undef N diff --git a/include/boost/functional/forward_adapter.hpp b/include/boost/functional/forward_adapter.hpp index 6023fc2..0d486a6 100644 --- a/include/boost/functional/forward_adapter.hpp +++ b/include/boost/functional/forward_adapter.hpp @@ -10,7 +10,7 @@ # ifndef BOOST_PP_IS_ITERATING # include -# include +# include # include # include diff --git a/include/boost/functional/hash.hpp b/include/boost/functional/hash.hpp deleted file mode 100644 index 44983f1..0000000 --- a/include/boost/functional/hash.hpp +++ /dev/null @@ -1,7 +0,0 @@ - -// 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/functional/hash/detail/float_functions.hpp deleted file mode 100644 index f3db52f..0000000 --- a/include/boost/functional/hash/detail/float_functions.hpp +++ /dev/null @@ -1,336 +0,0 @@ - -// 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) - -#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP) -#define BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP - -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include - -// Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have -// sufficiently good floating point support to not require any -// workarounds. -// -// When set to 0, the library tries to automatically -// use the best available implementation. This normally works well, but -// breaks when ambiguities are created by odd namespacing of the functions. -// -// Note that if this is set to 0, the library should still take full -// advantage of the platform's floating point support. - -#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif defined(__LIBCOMO__) -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) -// Rogue Wave library: -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif defined(_LIBCPP_VERSION) -// libc++ -# define BOOST_HASH_CONFORMANT_FLOATS 1 -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) -// GNU libstdc++ 3 -# if defined(__GNUC__) && __GNUC__ >= 4 -# define BOOST_HASH_CONFORMANT_FLOATS 1 -# else -# define BOOST_HASH_CONFORMANT_FLOATS 0 -# endif -#elif defined(__STL_CONFIG_H) -// generic SGI STL -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif defined(__MSL_CPP__) -// MSL standard lib: -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif defined(__IBMCPP__) -// VACPP std lib (probably conformant for much earlier version). -# if __IBMCPP__ >= 1210 -# define BOOST_HASH_CONFORMANT_FLOATS 1 -# else -# define BOOST_HASH_CONFORMANT_FLOATS 0 -# endif -#elif defined(MSIPL_COMPILE_H) -// Modena C++ standard library -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) -// Dinkumware Library (this has to appear after any possible replacement libraries): -# if _CPPLIB_VER >= 405 -# define BOOST_HASH_CONFORMANT_FLOATS 1 -# else -# define BOOST_HASH_CONFORMANT_FLOATS 0 -# endif -#else -# define BOOST_HASH_CONFORMANT_FLOATS 0 -#endif - -#if BOOST_HASH_CONFORMANT_FLOATS - -// The standard library is known to be compliant, so don't use the -// configuration mechanism. - -namespace boost { - namespace hash_detail { - template - struct call_ldexp { - typedef Float float_type; - inline Float operator()(Float x, int y) const { - return std::ldexp(x, y); - } - }; - - template - struct call_frexp { - typedef Float float_type; - inline Float operator()(Float x, int* y) const { - return std::frexp(x, y); - } - }; - - template - struct select_hash_type - { - typedef Float type; - }; - } -} - -#else // BOOST_HASH_CONFORMANT_FLOATS == 0 - -// The C++ standard requires that the C float functions are overloarded -// for float, double and long double in the std namespace, but some of the older -// library implementations don't support this. On some that don't, the C99 -// float functions (frexpf, frexpl, etc.) are available. -// -// The following tries to automatically detect which are available. - -namespace boost { - namespace hash_detail { - - // Returned by dummy versions of the float functions. - - struct not_found { - // Implicitly convertible to float and long double in order to avoid - // a compile error when the dummy float functions are used. - - inline operator float() const { return 0; } - inline operator long double() const { return 0; } - }; - - // A type for detecting the return type of functions. - - template struct is; - template <> struct is { char x[10]; }; - template <> struct is { char x[20]; }; - template <> struct is { char x[30]; }; - template <> struct is { char x[40]; }; - - // Used to convert the return type of a function to a type for sizeof. - - template is float_type(T); - - // call_ldexp - // - // This will get specialized for float and long double - - template struct call_ldexp - { - typedef double float_type; - - inline double operator()(double a, int b) const - { - using namespace std; - return ldexp(a, b); - } - }; - - // call_frexp - // - // This will get specialized for float and long double - - template struct call_frexp - { - typedef double float_type; - - inline double operator()(double a, int* b) const - { - using namespace std; - return frexp(a, b); - } - }; - } -} - -// A namespace for dummy functions to detect when the actual function we want -// isn't available. ldexpl, ldexpf etc. might be added tby the macros below. -// -// AFAICT these have to be outside of the boost namespace, as if they're in -// the boost namespace they'll always be preferable to any other function -// (since the arguments are built in types, ADL can't be used). - -namespace boost_hash_detect_float_functions { - template boost::hash_detail::not_found ldexp(Float, int); - template boost::hash_detail::not_found frexp(Float, int*); -} - -// Macros for generating specializations of call_ldexp and call_frexp. -// -// check_cpp and check_c99 check if the C++ or C99 functions are available. -// -// Then the call_* functions select an appropriate implementation. -// -// I used c99_func in a few places just to get a unique name. -// -// Important: when using 'using namespace' at namespace level, include as -// little as possible in that namespace, as Visual C++ has an odd bug which -// can cause the namespace to be imported at the global level. This seems to -// happen mainly when there's a template in the same namesapce. - -#define BOOST_HASH_CALL_FLOAT_FUNC(cpp_func, c99_func, type1, type2) \ -namespace boost_hash_detect_float_functions { \ - template \ - boost::hash_detail::not_found c99_func(Float, type2); \ -} \ - \ -namespace boost { \ - namespace hash_detail { \ - namespace c99_func##_detect { \ - using namespace std; \ - using namespace boost_hash_detect_float_functions; \ - \ - struct check { \ - static type1 x; \ - static type2 y; \ - BOOST_STATIC_CONSTANT(bool, cpp = \ - sizeof(float_type(cpp_func(x,y))) \ - == sizeof(is)); \ - BOOST_STATIC_CONSTANT(bool, c99 = \ - sizeof(float_type(c99_func(x,y))) \ - == sizeof(is)); \ - }; \ - } \ - \ - template \ - struct call_c99_##c99_func : \ - boost::hash_detail::call_##cpp_func {}; \ - \ - template <> \ - struct call_c99_##c99_func { \ - typedef type1 float_type; \ - \ - template \ - inline type1 operator()(type1 a, T b) const \ - { \ - using namespace std; \ - return c99_func(a, b); \ - } \ - }; \ - \ - template \ - struct call_cpp_##c99_func : \ - call_c99_##c99_func< \ - ::boost::hash_detail::c99_func##_detect::check::c99 \ - > {}; \ - \ - template <> \ - struct call_cpp_##c99_func { \ - typedef type1 float_type; \ - \ - template \ - inline type1 operator()(type1 a, T b) const \ - { \ - using namespace std; \ - return cpp_func(a, b); \ - } \ - }; \ - \ - template <> \ - struct call_##cpp_func : \ - call_cpp_##c99_func< \ - ::boost::hash_detail::c99_func##_detect::check::cpp \ - > {}; \ - } \ -} - -#define BOOST_HASH_CALL_FLOAT_MACRO(cpp_func, c99_func, type1, type2) \ -namespace boost { \ - namespace hash_detail { \ - \ - template <> \ - struct call_##cpp_func { \ - typedef type1 float_type; \ - inline type1 operator()(type1 x, type2 y) const { \ - return c99_func(x, y); \ - } \ - }; \ - } \ -} - -#if defined(ldexpf) -BOOST_HASH_CALL_FLOAT_MACRO(ldexp, ldexpf, float, int) -#else -BOOST_HASH_CALL_FLOAT_FUNC(ldexp, ldexpf, float, int) -#endif - -#if defined(ldexpl) -BOOST_HASH_CALL_FLOAT_MACRO(ldexp, ldexpl, long double, int) -#else -BOOST_HASH_CALL_FLOAT_FUNC(ldexp, ldexpl, long double, int) -#endif - -#if defined(frexpf) -BOOST_HASH_CALL_FLOAT_MACRO(frexp, frexpf, float, int*) -#else -BOOST_HASH_CALL_FLOAT_FUNC(frexp, frexpf, float, int*) -#endif - -#if defined(frexpl) -BOOST_HASH_CALL_FLOAT_MACRO(frexp, frexpl, long double, int*) -#else -BOOST_HASH_CALL_FLOAT_FUNC(frexp, frexpl, long double, int*) -#endif - -#undef BOOST_HASH_CALL_FLOAT_MACRO -#undef BOOST_HASH_CALL_FLOAT_FUNC - - -namespace boost -{ - namespace hash_detail - { - template - struct select_hash_type_impl { - typedef double type; - }; - - template <> - struct select_hash_type_impl { - typedef float type; - }; - - template <> - struct select_hash_type_impl { - typedef long double type; - }; - - - // select_hash_type - // - // If there is support for a particular floating point type, use that - // otherwise use double (there's always support for double). - - template - struct select_hash_type : select_hash_type_impl< - BOOST_DEDUCED_TYPENAME call_ldexp::float_type, - BOOST_DEDUCED_TYPENAME call_frexp::float_type - > {}; - } -} - -#endif // BOOST_HASH_CONFORMANT_FLOATS - -#endif diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp deleted file mode 100644 index 1816c57..0000000 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ /dev/null @@ -1,271 +0,0 @@ - -// Copyright 2005-2012 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) - -#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER) -#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER - -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(BOOST_MSVC) -#pragma warning(push) -#if BOOST_MSVC >= 1400 -#pragma warning(disable:6294) // Ill-defined for-loop: initial condition does - // not satisfy test. Loop body not executed -#endif -#endif - -// Can we use fpclassify? - -// STLport -#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) -#define BOOST_HASH_USE_FPCLASSIFY 0 - -// GNU libstdc++ 3 -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) -# if (defined(__USE_ISOC99) || defined(_GLIBCXX_USE_C99_MATH)) && \ - !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) -# define BOOST_HASH_USE_FPCLASSIFY 1 -# else -# define BOOST_HASH_USE_FPCLASSIFY 0 -# endif - -// Everything else -#else -# define BOOST_HASH_USE_FPCLASSIFY 0 -#endif - -namespace boost -{ - namespace hash_detail - { - inline void hash_float_combine(std::size_t& seed, std::size_t value) - { - seed ^= value + (seed<<6) + (seed>>2); - } - - //////////////////////////////////////////////////////////////////////// - // Binary hash function - // - // Only used for floats with known iec559 floats, and certain values in - // numeric_limits - - inline std::size_t hash_binary(char* ptr, std::size_t length) - { - std::size_t seed = 0; - - if (length >= sizeof(std::size_t)) { - std::memcpy(&seed, ptr, sizeof(std::size_t)); - length -= sizeof(std::size_t); - ptr += sizeof(std::size_t); - - while(length >= sizeof(std::size_t)) { - std::size_t buffer = 0; - std::memcpy(&buffer, ptr, sizeof(std::size_t)); - hash_float_combine(seed, buffer); - length -= sizeof(std::size_t); - ptr += sizeof(std::size_t); - } - } - - if (length > 0) { - std::size_t buffer = 0; - std::memcpy(&buffer, ptr, length); - hash_float_combine(seed, buffer); - } - - return seed; - } - - template - struct enable_binary_hash - { - BOOST_STATIC_CONSTANT(bool, value = - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == digits && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == max_exponent); - }; - - template - inline std::size_t float_hash_impl(Float v, - BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, - std::size_t>::type) - { - return hash_binary((char*) &v, 4); - } - - - template - inline std::size_t float_hash_impl(Float v, - BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, - std::size_t>::type) - { - return hash_binary((char*) &v, 8); - } - - template - inline std::size_t float_hash_impl(Float v, - BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, - std::size_t>::type) - { - return hash_binary((char*) &v, 10); - } - - template - inline std::size_t float_hash_impl(Float v, - BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, - std::size_t>::type) - { - return hash_binary((char*) &v, 16); - } - - //////////////////////////////////////////////////////////////////////// - // Portable hash function - // - // Used as a fallback when the binary hash function isn't supported. - - template - inline std::size_t float_hash_impl2(T v) - { - boost::hash_detail::call_frexp frexp; - boost::hash_detail::call_ldexp ldexp; - - int exp = 0; - - v = frexp(v, &exp); - - // A postive value is easier to hash, so combine the - // sign with the exponent and use the absolute value. - if(v < 0) { - v = -v; - exp += limits::max_exponent - - limits::min_exponent; - } - - v = ldexp(v, limits::digits); - std::size_t seed = static_cast(v); - v -= static_cast(seed); - - // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1; - std::size_t const length - = (limits::digits * - boost::static_log2::radix>::value - + limits::digits - 1) - / limits::digits; - - for(std::size_t i = 0; i != length; ++i) - { - v = ldexp(v, limits::digits); - std::size_t part = static_cast(v); - v -= static_cast(part); - hash_float_combine(seed, part); - } - - hash_float_combine(seed, static_cast(exp)); - - return seed; - } - -#if !defined(BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC) - template - inline std::size_t float_hash_impl(T v, ...) - { - typedef BOOST_DEDUCED_TYPENAME select_hash_type::type type; - return float_hash_impl2(static_cast(v)); - } -#endif - } -} - -#if BOOST_HASH_USE_FPCLASSIFY - -#include - -namespace boost -{ - namespace hash_detail - { - template - inline std::size_t float_hash_value(T v) - { -#if defined(fpclassify) - switch (fpclassify(v)) -#elif BOOST_HASH_CONFORMANT_FLOATS - switch (std::fpclassify(v)) -#else - using namespace std; - switch (fpclassify(v)) -#endif - { - case FP_ZERO: - return 0; - case FP_INFINITE: - return (std::size_t)(v > 0 ? -1 : -2); - case FP_NAN: - return (std::size_t)(-3); - case FP_NORMAL: - case FP_SUBNORMAL: - return float_hash_impl(v, 0); - default: - BOOST_ASSERT(0); - return 0; - } - } - } -} - -#else // !BOOST_HASH_USE_FPCLASSIFY - -namespace boost -{ - namespace hash_detail - { - template - inline bool is_zero(T v) - { -#if !defined(__GNUC__) && !defined(__clang__) - return v == 0; -#else - // GCC's '-Wfloat-equal' will complain about comparing - // v to 0, but because it disables warnings for system - // headers it won't complain if you use std::equal_to to - // compare with 0. Resulting in this silliness: - return std::equal_to()(v, 0); -#endif - } - - template - inline std::size_t float_hash_value(T v) - { - return boost::hash_detail::is_zero(v) ? 0 : float_hash_impl(v, 0); - } - } -} - -#endif // BOOST_HASH_USE_FPCLASSIFY - -#undef BOOST_HASH_USE_FPCLASSIFY - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#endif diff --git a/include/boost/functional/hash/detail/limits.hpp b/include/boost/functional/hash/detail/limits.hpp deleted file mode 100644 index 4a971a6..0000000 --- a/include/boost/functional/hash/detail/limits.hpp +++ /dev/null @@ -1,62 +0,0 @@ - -// 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) -// -// On some platforms std::limits gives incorrect values for long double. -// This tries to work around them. - -#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER) -#define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER - -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - -#include - -// On OpenBSD, numeric_limits is not reliable for long doubles, but -// the macros defined in are and support long double when STLport -// doesn't. - -#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE) -#include -#endif - -namespace boost -{ - namespace hash_detail - { - template - struct limits : std::numeric_limits {}; - -#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE) - template <> - struct limits - : std::numeric_limits - { - static long double epsilon() { - return LDBL_EPSILON; - } - - static long double (max)() { - return LDBL_MAX; - } - - static long double (min)() { - return LDBL_MIN; - } - - BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG); - BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP); - BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP); -#if defined(_STLP_NO_LONG_DOUBLE) - BOOST_STATIC_CONSTANT(int, radix = FLT_RADIX); -#endif - }; -#endif // __OpenBSD__ - } -} - -#endif diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp deleted file mode 100644 index cb3c856..0000000 --- a/include/boost/functional/hash/extensions.hpp +++ /dev/null @@ -1,318 +0,0 @@ - -// 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 -#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 diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp deleted file mode 100644 index b461f5f..0000000 --- a/include/boost/functional/hash/hash.hpp +++ /dev/null @@ -1,595 +0,0 @@ - -// 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/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp deleted file mode 100644 index 01fe012..0000000 --- a/include/boost/functional/hash/hash_fwd.hpp +++ /dev/null @@ -1,36 +0,0 @@ - -// 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 -#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 diff --git a/include/boost/functional/hash_fwd.hpp b/include/boost/functional/hash_fwd.hpp deleted file mode 100644 index eea9073..0000000 --- a/include/boost/functional/hash_fwd.hpp +++ /dev/null @@ -1,11 +0,0 @@ - -// 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/lightweight_forward_adapter.hpp b/include/boost/functional/lightweight_forward_adapter.hpp index 2706d29..4c0d864 100644 --- a/include/boost/functional/lightweight_forward_adapter.hpp +++ b/include/boost/functional/lightweight_forward_adapter.hpp @@ -10,7 +10,7 @@ # ifndef BOOST_PP_IS_ITERATING # include -# include +# include # include # include diff --git a/meta/explicit-failures-markup.xml b/meta/explicit-failures-markup.xml index 413753d..2fb459a 100644 --- a/meta/explicit-failures-markup.xml +++ b/meta/explicit-failures-markup.xml @@ -24,92 +24,4 @@ - - - - - - - - - hash_value is not overloaded for arrays for older versions - of Visual C++. There is a work around so that - boost::hash<T[N]>, boost::hash_combine and boost::hash_range - work. - - - - - - - - - - - - - - - - - On these compilers the wrong overload of hash_value is called - when the argument is a hash function pointer. So calling - hash_value doesn't work but boost::hash does work (and it's - recommended that user never call hash_value directly so this - shouldn't be a problem). - - - - - - - - - This platform has poor support for long double so - the hash function perform poorly for values out of the range - of double or if they differ at a greater precision - that double is capable of representing. - - - - - - - - - - These examples only work on compilers with support for ADL. - It is possible to work around this, but I wanted to keep the - example code as clean as possible. - - - - - - - - It appears that Borland doesn't find friend functions defined - in a class by ADL. This is easily fixed but this example is - meant to show the typical way of customising boost::hash, not - the portable way. - - - - - - - - The test demonstrates a Borland bug - functions that aren't - in a namespace don't appear to be found by ADL. - - - - - - - - Debug containers aren't supported on Apple's version of gcc 4.2. - - - diff --git a/meta/libraries.json b/meta/libraries.json index 675bd6f..7b191f2 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -43,25 +43,6 @@ "Function-objects" ] }, - { - "key": "functional/hash", - "boost-version": "1.33.0", - "name": "Functional/Hash", - "authors": [ - "Daniel James" - ], - "maintainers": [ - "Daniel James " - ], - "description": "A TR1 hash function object that can be extended to hash user defined types.", - "documentation": "hash/", - "std": [ - "tr1" - ], - "category": [ - "Function-objects" - ] - }, { "key": "functional/overloaded_function", "boost-version": "1.50.0", @@ -78,4 +59,4 @@ "Function-objects" ] } -] \ No newline at end of file +] diff --git a/overloaded_function/doc/html/boost/make_overloaded_function.html b/overloaded_function/doc/html/boost/make_overloaded_function.html index 21f5f39..bc31be5 100644 --- a/overloaded_function/doc/html/boost/make_overloaded_function.html +++ b/overloaded_function/doc/html/boost/make_overloaded_function.html @@ -3,11 +3,11 @@ Function template make_overloaded_function - + - + @@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext
@@ -33,15 +33,15 @@ template<typename F1, typename F2, ... > - overloaded_function< __function_type__< F1 >, __function_type__< F2 >,...> + overloaded_function< __function_type__< F1 >, __function_type__< F2 >,... > make_overloaded_function(F1 f1, F2 f2, ...);
-

Description

-

This function template creates and returns an overloaded_function object that overloads all the specified functions f1, f2, etc.

-

The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with overloaded_function. This is especially useful when the explicit type of the returned overloaded_function object does not need to be known (e.g., when used with Boost.Typeof's BOOST_AUTO, C++11 auto, or when the overloaded function object is handled using a function template parameter, see the Tutorial section).

-

The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro.

+

Description

+

This function template creates and returns an overloaded_function object that overloads all the specified functions f1, f2, etc.

+

The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with overloaded_function. This is especially useful when the explicit type of the returned overloaded_function object does not need to be known (e.g., when used with Boost.Typeof's BOOST_AUTO, C++11 auto, or when the overloaded function object is handled using a function template parameter, see the Tutorial section).

+

The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro.

Note: In this documentation, __function_type__ is a placeholder for a symbol that is specific to the implementation of this library.

-

See: Tutorial section, overloaded_function, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.

+

See: Tutorial section, overloaded_function, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.

@@ -54,7 +54,7 @@

-PrevUpHomeNext +PrevUpHomeNext
diff --git a/overloaded_function/doc/html/boost/overloaded_function.html b/overloaded_function/doc/html/boost/overloaded_function.html index c8c600f..8b449df 100644 --- a/overloaded_function/doc/html/boost/overloaded_function.html +++ b/overloaded_function/doc/html/boost/overloaded_function.html @@ -3,7 +3,7 @@ Class template overloaded_function - + @@ -35,19 +35,19 @@ class overloaded_function { public: // construct/copy/destruct - overloaded_function(const boost::function< F1 > &, + overloaded_function(const boost::function< F1 > &, const boost::function< F2 > &, ...); - // public member functions + // public member functions boost::function_traits< F1 >::result_type - operator()(typename boost::function_traits< F1 >::arg1_type, + operator()(typename boost::function_traits< F1 >::arg1_type, typename boost::function_traits< F1 >::arg2_type, ...) const; boost::function_traits< F2 >::result_type - operator()(typename boost::function_traits< F2 >::arg1_type, + operator()(typename boost::function_traits< F2 >::arg1_type, typename boost::function_traits< F2 >::arg2_type, ...) const; };
-

Description

+

Description

This function object aggregates together calls to functions of all the specified function types F1, F2, etc which must have distinct function signatures from one another.

Parameters:

@@ -57,38 +57,38 @@ -
FiEach function type must be specified using the following syntax (which is Boost.Function's preferred syntax):
    result_type (argument1_type, argumgnet2_type, ...)
+
Each function type must be specified using the following syntax (which is Boost.Function's preferred syntax):
result_type (argument1_type, argumgnet2_type, ...)
 

-

In some cases, the make_overloaded_function function template can be useful to construct an overloaded function object without explicitly specifying the function types.

-

At least two distinct function types must be specified (because there is nothing to overload between one or zero functions). The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro. The maximum number of function parameters for each of the specified function types is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX configuration macro.

-

See: Tutorial section, make_overloaded_function, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX, Boost.Function.

+

In some cases, the make_overloaded_function function template can be useful to construct an overloaded function object without explicitly specifying the function types.

+

At least two distinct function types must be specified (because there is nothing to overload between one or zero functions). The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro. The maximum number of function parameters for each of the specified function types is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX configuration macro.

+

See: Tutorial section, make_overloaded_function, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX, Boost.Function.

-

+

overloaded_function public construct/copy/destruct

  1. -
    overloaded_function(const boost::function< F1 > &, 
    +
    overloaded_function(const boost::function< F1 > &, 
                         const boost::function< F2 > &, ...);
    Construct the overloaded function object.

    Any function pointer, function reference, and monomorphic function object that can be converted to a boost::function function object can be specified as parameter.

    Note: Unfortunately, it is not possible to support polymorphic function objects (as explained here).

-

-overloaded_function public member functions

+

+overloaded_function public member functions

  1. boost::function_traits< F1 >::result_type 
    -operator()(typename boost::function_traits< F1 >::arg1_type, 
    +operator()(typename boost::function_traits< F1 >::arg1_type, 
                typename boost::function_traits< F1 >::arg2_type, ...) const;
    Call operator matching the signature of the function type specified as 1st template parameter.

    This will in turn invoke the call operator of the 1st function passed to the constructor.

  2. boost::function_traits< F2 >::result_type 
    -operator()(typename boost::function_traits< F2 >::arg1_type, 
    +operator()(typename boost::function_traits< F2 >::arg1_type, 
                typename boost::function_traits< F2 >::arg2_type, ...) const;
    Call operator matching the signature of the function type specified as 2nd template parameter.

    This will in turn invoke the call operator of the 2nd function passed to the constructor.

    Note: Similar call operators are present for all specified function types F1, F2, etc (even if not exhaustively listed by this documentation).

  3. diff --git a/overloaded_function/doc/html/boost_functional_overloadedfunction/acknowledgments.html b/overloaded_function/doc/html/boost_functional_overloadedfunction/acknowledgments.html index 605d481..0d4d295 100644 --- a/overloaded_function/doc/html/boost_functional_overloadedfunction/acknowledgments.html +++ b/overloaded_function/doc/html/boost_functional_overloadedfunction/acknowledgments.html @@ -3,10 +3,10 @@ Acknowledgments - + - + @@ -19,9 +19,9 @@

    -PrevUpHome +PrevUpHome
    -
    +
    @@ -54,7 +54,7 @@
    -PrevUpHome +PrevUpHome
    diff --git a/overloaded_function/doc/html/boost_functional_overloadedfunction/getting_started.html b/overloaded_function/doc/html/boost_functional_overloadedfunction/getting_started.html index 459e7d5..a05da4a 100644 --- a/overloaded_function/doc/html/boost_functional_overloadedfunction/getting_started.html +++ b/overloaded_function/doc/html/boost_functional_overloadedfunction/getting_started.html @@ -3,7 +3,7 @@ Getting Started - + @@ -22,7 +22,7 @@
    PrevUpHomeNext
    -
    +

    Getting Started @@ -35,7 +35,7 @@

    This section explains how to setup a system to use this library.

    -
    +

    Compilers and Platforms @@ -60,7 +60,7 @@ for any special configuration that might be required for a specific compiler.

    -
    +
    @@ -71,9 +71,9 @@ using the library.

    - The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX + The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro. The maximum number of function parameters for each of - the specified function type is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX + the specified function type is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX configuration macro. All configuration macros have appropriate default values when they are left undefined.

    diff --git a/overloaded_function/doc/html/boost_functional_overloadedfunction/tutorial.html b/overloaded_function/doc/html/boost_functional_overloadedfunction/tutorial.html index 98493ac..132ae1d 100644 --- a/overloaded_function/doc/html/boost_functional_overloadedfunction/tutorial.html +++ b/overloaded_function/doc/html/boost_functional_overloadedfunction/tutorial.html @@ -3,7 +3,7 @@ Tutorial - + @@ -22,7 +22,7 @@
    PrevUpHomeNext
    -
    +
    @@ -34,7 +34,7 @@

    This section explains how to use this library.

    -
    +
    @@ -87,7 +87,7 @@

    Then the relative function pointers, function references, or monomorphic function objects are passed to the boost::overloaded_function - constructor matching the order of the specified template parameters. [2] In the above example, identity_s + constructor matching the order of the specified template parameters. [2] In the above example, identity_s is passed as a function pointer (the function address is automatically taken from the function name by the compiler), identity_i as a function reference, and identity_d @@ -95,12 +95,12 @@

    All specified function types must have distinct parameters from one another - (so the overloaded calls can be resolved by this library). [3] In order to create an overloaded function object, it is necessary + (so the overloaded calls can be resolved by this library). [3] In order to create an overloaded function object, it is necessary to specify at least two function types (because there is nothing to overload between one or zero functions).

    -
    +

    Without Function Types @@ -188,8 +188,8 @@

    -

    -

    [2] +


    +

    [2] Function pointers are of the form result-type (*)(argument1-type, ...) (the C++ compiler is usually able to automatically promote a function name to a function pointer in a context where a function pointer is expected even @@ -204,7 +204,7 @@ Unfortunately, it is not possible to support polymorphic function objects (see http://lists.boost.org/Archives/boost/2012/03/191744.php).

    -

    [3] +

    [3] Note that in C++ the function result type is not used for overload resolution (to avoid making the overload resolution context dependent). Therefore, at least one of the function parameters must be distinct for each specified diff --git a/overloaded_function/doc/html/index.html b/overloaded_function/doc/html/index.html index 5e6c0e9..b8e5881 100644 --- a/overloaded_function/doc/html/index.html +++ b/overloaded_function/doc/html/index.html @@ -3,7 +3,7 @@ Chapter 1. Boost.Functional/OverloadedFunction 1.0.0 - + @@ -61,7 +61,7 @@

    This library allows to overload different functions into a single function object.

    -
    +
    @@ -84,7 +84,7 @@

    Instead of calling them using their separate names (here BOOST_TEST is equivalent to assert): - [1] + [1]

    @@ -124,21 +124,21 @@

    -

    -

    [1] - In most of the examples presented in this documentation, the Boost.Detail/LightweightTest - (boost/detail/lightweight_test.hpp) macro BOOST_TEST is used to check correctness +


    +

    [1] + In most of the examples presented in this documentation, the Boost.Core/LightweightTest + (boost/core/lightweight_test.hpp) macro BOOST_TEST is used to check correctness conditions (conceptually similar to assert). A failure of the checked condition does not abort the execution of the program, it will instead make boost::report_errors - return a non-zero program exit code. Using Boost.Detail/LightweightTest allows + return a non-zero program exit code. Using Boost.Core/LightweightTest allows to add the examples to the library regression tests so to make sure that they always compile and run correctly.

    - +

    Last revised: April 28, 2012 at 02:19:13 GMT

    Last revised: December 03, 2017 at 14:34:49 GMT


    diff --git a/overloaded_function/doc/html/reference.html b/overloaded_function/doc/html/reference.html index 55a89f0..b7c14b0 100644 --- a/overloaded_function/doc/html/reference.html +++ b/overloaded_function/doc/html/reference.html @@ -3,7 +3,7 @@ Reference - + @@ -22,32 +22,32 @@
    PrevUpHomeNext
    -
    +

    Reference

    -
    +

    Overload distinct function pointers, function references, and monomorphic function objects into a single function object.

    namespace boost {
       template<typename F1, typename F2, ... > class overloaded_function;
       template<typename F1, typename F2, ... > 
    -    overloaded_function< __function_type__< F1 >, __function_type__< F2 >,...> 
    +    overloaded_function< __function_type__< F1 >, __function_type__< F2 >,... > 
         make_overloaded_function(F1, F2, ...);
     }
    - diff --git a/overloaded_function/doc/overloaded_function.qbk b/overloaded_function/doc/overloaded_function.qbk index 6cf6964..378793c 100644 --- a/overloaded_function/doc/overloaded_function.qbk +++ b/overloaded_function/doc/overloaded_function.qbk @@ -42,9 +42,9 @@ Consider the following functions which have distinct signatures: Instead of calling them using their separate names (here `BOOST_TEST` is equivalent to `assert`): [footnote -In most of the examples presented in this documentation, the Boost.Detail/LightweightTest (=boost/detail/lightweight_test.hpp=) macro `BOOST_TEST` is used to check correctness conditions (conceptually similar to `assert`). +In most of the examples presented in this documentation, the Boost.Core/LightweightTest (=boost/core/lightweight_test.hpp=) macro `BOOST_TEST` is used to check correctness conditions (conceptually similar to `assert`). A failure of the checked condition does not abort the execution of the program, it will instead make `boost::report_errors` return a non-zero program exit code. -Using Boost.Detail/LightweightTest allows to add the examples to the library regression tests so to make sure that they always compile and run correctly. +Using Boost.Core/LightweightTest allows to add the examples to the library regression tests so to make sure that they always compile and run correctly. ] [identity_calls] diff --git a/overloaded_function/test/functor.cpp b/overloaded_function/test/functor.cpp index 86827fc..2df52e7 100644 --- a/overloaded_function/test/functor.cpp +++ b/overloaded_function/test/functor.cpp @@ -7,7 +7,7 @@ #include "identity.hpp" #include -#include +#include int main() { //[identity_calls diff --git a/overloaded_function/test/make_call.cpp b/overloaded_function/test/make_call.cpp index e2abdde..89ffab0 100644 --- a/overloaded_function/test/make_call.cpp +++ b/overloaded_function/test/make_call.cpp @@ -7,7 +7,7 @@ #include "identity.hpp" #include -#include +#include //[identity_make_checks template diff --git a/overloaded_function/test/make_decl.cpp b/overloaded_function/test/make_decl.cpp index 6f5cbdf..ea3bac6 100644 --- a/overloaded_function/test/make_decl.cpp +++ b/overloaded_function/test/make_decl.cpp @@ -8,7 +8,7 @@ #include "identity.hpp" #include #include -#include +#include int main() { //[identity_make_decl