Merge branch 'develop'

This commit is contained in:
Daniel James
2018-04-04 00:33:22 +01:00
5 changed files with 92 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ environment:
TOOLSET: msvc-14.0 TOOLSET: msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1 TOOLSET: msvc-14.1
CXXSTD: 14,17
install: install:
- cd c:\projects - cd c:\projects
@@ -29,5 +30,7 @@ install:
build: off build: off
test_script: test_script:
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- cd %APPVEYOR_BUILD_FOLDER%\test - 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%

View File

@@ -216,5 +216,7 @@
preprocessor to generate them. Should improve usability, due preprocessor to generate them. Should improve usability, due
to better error messages, and easier debugging. to better error messages, and easier debugging.
* Fix tutorial example ([ticket 11017]). * 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] [endsect]

View File

@@ -22,6 +22,7 @@
#include <boost/detail/container_fwd.hpp> #include <boost/detail/container_fwd.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <vector>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) #if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array> # include <array>
@@ -70,6 +71,56 @@ namespace boost
return seed; 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> template <class T, class A>
std::size_t hash_value(std::vector<T, A> const& v) std::size_t hash_value(std::vector<T, A> const& v)
{ {

View File

@@ -39,7 +39,8 @@ void write_compiler_info() {
{1900, "Visual C++ 14.00, VS2015"}, {1900, "Visual C++ 14.00, VS2015"},
{1910, "Visual C++ 14.10, VS2017 15.1/2"}, {1910, "Visual C++ 14.10, VS2017 15.1/2"},
{1911, "Visual C++ 14.11, VS2017 15.3/4"}, {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, "" }; msvc_version msvc = { BOOST_MSVC, "" };

View File

@@ -25,11 +25,44 @@ using std::vector;
#endif // BOOST_HASH_TEST_EXTENSIONS #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() int main()
{ {
#ifdef BOOST_HASH_TEST_EXTENSIONS #ifdef BOOST_HASH_TEST_EXTENSIONS
vector_tests::vector_hash_integer_tests(); vector_tests::vector_hash_integer_tests();
#endif #endif
vector_bool_tests::vector_bool_test();
return boost::report_errors(); return boost::report_errors();
} }