forked from boostorg/container_hash
Merge branch 'develop'
This commit is contained in:
@@ -201,4 +201,20 @@
|
|||||||
already in place for GCC, and was used when Clang pretends to be GCC,
|
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.
|
but the warning was appearing when running Clang in other contexts.
|
||||||
|
|
||||||
|
[h2 Boost 1.67.0]
|
||||||
|
|
||||||
|
* Moved library into its own module, `container_hash`.
|
||||||
|
* Moved headers for new module name, now at:
|
||||||
|
`<boost/container_hash/hash.hpp>`,
|
||||||
|
`<boost/container_hash/hash_fwd.hpp>`,
|
||||||
|
`<boost/container_hash/extensions.hpp>`.
|
||||||
|
* Added forwarding headers to support the old headers locations.
|
||||||
|
* Support `std::string_view`, `std::error_code`, `std::error_condition`
|
||||||
|
`std::optional`, `std::variant`, `std::monostate` where available.
|
||||||
|
* Update include paths from other Boost libraries.
|
||||||
|
* Manually write out tuple overloads, rather than using the
|
||||||
|
preprocessor to generate them. Should improve usability, due
|
||||||
|
to better error messages, and easier debugging.
|
||||||
|
* Fix tutorial example ([ticket 11017]).
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
27
doc/samples/tutorial.cpp
Normal file
27
doc/samples/tutorial.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include <boost/container_hash/hash.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
//[ get_hashes
|
||||||
|
template <class Container>
|
||||||
|
std::vector<std::size_t> get_hashes(Container const& x)
|
||||||
|
{
|
||||||
|
std::vector<std::size_t> hashes;
|
||||||
|
std::transform(x.begin(), x.end(), std::back_inserter(hashes),
|
||||||
|
boost::hash<typename Container::value_type>());
|
||||||
|
|
||||||
|
return hashes;
|
||||||
|
}
|
||||||
|
//]
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::vector<int> values;
|
||||||
|
values.push_back(10);
|
||||||
|
values.push_back(20);
|
||||||
|
|
||||||
|
std::vector<std::size_t> hashes = get_hashes(values);
|
||||||
|
assert(hashes[0] = boost::hash<int>()(values[0]));
|
||||||
|
assert(hashes[1] = boost::hash<int>()(values[1]));
|
||||||
|
}
|
@@ -3,6 +3,9 @@
|
|||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
[quickbook 1.7]
|
||||||
|
[import samples/tutorial.cpp]
|
||||||
|
|
||||||
[def __multi-index-short__ [@boost:/libs/multi_index/doc/index.html
|
[def __multi-index-short__ [@boost:/libs/multi_index/doc/index.html
|
||||||
Boost.MultiIndex]]
|
Boost.MultiIndex]]
|
||||||
|
|
||||||
@@ -39,15 +42,7 @@ To use [classref boost::hash] directly, create an instance and call it as a func
|
|||||||
For an example of generic use, here is a function to generate a vector
|
For an example of generic use, here is a function to generate a vector
|
||||||
containing the hashes of the elements of a container:
|
containing the hashes of the elements of a container:
|
||||||
|
|
||||||
template <class Container>
|
[get_hashes]
|
||||||
std::vector<std::size_t> get_hashes(Container const& x)
|
|
||||||
{
|
|
||||||
std::vector<std::size_t> hashes;
|
|
||||||
std::transform(x.begin(), x.end(), std::insert_iterator(hashes),
|
|
||||||
``[classref boost::hash]``<typename Container::value_type>());
|
|
||||||
|
|
||||||
return hashes;
|
|
||||||
}
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user