forked from boostorg/container_hash
Merge branch 'develop'
This commit is contained in:
@@ -14,6 +14,7 @@ environment:
|
||||
TOOLSET: msvc-14.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
|
||||
install:
|
||||
- cd c:\projects
|
||||
@@ -29,5 +30,7 @@ install:
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test
|
||||
- cmd /c %BOOST_ROOT%\tools\build\b2 -j 3 toolset=%TOOLSET% include=%APPVEYOR_BUILD_FOLDER%\include include=%BOOST_ROOT%
|
||||
- cmd /c %BOOST_ROOT%\tools\build\b2 -j 3 toolset=%TOOLSET% %CXXSTD% include=%APPVEYOR_BUILD_FOLDER%\include include=%BOOST_ROOT% --verbose-test hash_info
|
||||
- cmd /c %BOOST_ROOT%\tools\build\b2 -j 3 toolset=%TOOLSET% %CXXSTD% include=%APPVEYOR_BUILD_FOLDER%\include include=%BOOST_ROOT%
|
||||
|
@@ -216,5 +216,7 @@
|
||||
preprocessor to generate them. Should improve usability, due
|
||||
to better error messages, and easier debugging.
|
||||
* Fix tutorial example ([ticket 11017]).
|
||||
* Quick fix for hashing `vector<bool>` when using libc++. Will try to introduce
|
||||
a more general fix in the next release.
|
||||
|
||||
[endsect]
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <boost/detail/container_fwd.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <vector>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
|
||||
# include <array>
|
||||
@@ -70,6 +71,56 @@ namespace boost
|
||||
return seed;
|
||||
}
|
||||
|
||||
inline std::size_t hash_range(
|
||||
std::vector<bool>::iterator first,
|
||||
std::vector<bool>::iterator last)
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
|
||||
for(; first != last; ++first)
|
||||
{
|
||||
hash_combine<bool>(seed, *first);
|
||||
}
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
||||
inline std::size_t hash_range(
|
||||
std::vector<bool>::const_iterator first,
|
||||
std::vector<bool>::const_iterator last)
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
|
||||
for(; first != last; ++first)
|
||||
{
|
||||
hash_combine<bool>(seed, *first);
|
||||
}
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
||||
inline void hash_range(
|
||||
std::size_t& seed,
|
||||
std::vector<bool>::iterator first,
|
||||
std::vector<bool>::iterator last)
|
||||
{
|
||||
for(; first != last; ++first)
|
||||
{
|
||||
hash_combine<bool>(seed, *first);
|
||||
}
|
||||
}
|
||||
|
||||
inline void hash_range(
|
||||
std::size_t& seed,
|
||||
std::vector<bool>::const_iterator first,
|
||||
std::vector<bool>::const_iterator last)
|
||||
{
|
||||
for(; first != last; ++first)
|
||||
{
|
||||
hash_combine<bool>(seed, *first);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class A>
|
||||
std::size_t hash_value(std::vector<T, A> const& v)
|
||||
{
|
||||
|
@@ -39,7 +39,8 @@ void write_compiler_info() {
|
||||
{1900, "Visual C++ 14.00, VS2015"},
|
||||
{1910, "Visual C++ 14.10, VS2017 15.1/2"},
|
||||
{1911, "Visual C++ 14.11, VS2017 15.3/4"},
|
||||
{1912, "Visual C++ 14.12, VS2017 15.5"}
|
||||
{1912, "Visual C++ 14.12, VS2017 15.5"},
|
||||
{1913, "Visual C++ 14.13, VS2017 15.6"}
|
||||
};
|
||||
|
||||
msvc_version msvc = { BOOST_MSVC, "" };
|
||||
|
@@ -25,11 +25,44 @@ using std::vector;
|
||||
|
||||
#endif // BOOST_HASH_TEST_EXTENSIONS
|
||||
|
||||
namespace vector_bool_tests
|
||||
{
|
||||
void vector_bool_test() {
|
||||
std::vector<bool> x_empty1,x_empty2,x1,x1a,x2,x3;
|
||||
|
||||
x1.push_back(0);
|
||||
x1a.push_back(0);
|
||||
x2.push_back(1);
|
||||
x3.push_back(0);
|
||||
x3.push_back(0);
|
||||
|
||||
BOOST_HASH_TEST_NAMESPACE::hash<std::vector<bool> > hasher;
|
||||
|
||||
BOOST_TEST_EQ(hasher(x_empty1), hasher(x_empty1));
|
||||
BOOST_TEST_EQ(hasher(x_empty1), hasher(x_empty2));
|
||||
BOOST_TEST_NE(hasher(x_empty1), hasher(x1));
|
||||
BOOST_TEST_NE(hasher(x_empty1), hasher(x2));
|
||||
BOOST_TEST_NE(hasher(x_empty1), hasher(x3));
|
||||
|
||||
BOOST_TEST_EQ(hasher(x1), hasher(x1));
|
||||
BOOST_TEST_EQ(hasher(x1), hasher(x1a));
|
||||
BOOST_TEST_NE(hasher(x1), hasher(x2));
|
||||
BOOST_TEST_NE(hasher(x1), hasher(x3));
|
||||
|
||||
BOOST_TEST_EQ(hasher(x2), hasher(x2));
|
||||
BOOST_TEST_NE(hasher(x2), hasher(x3));
|
||||
|
||||
BOOST_TEST_EQ(hasher(x3), hasher(x3));
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef BOOST_HASH_TEST_EXTENSIONS
|
||||
vector_tests::vector_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
vector_bool_tests::vector_bool_test();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user