BPHash
General object hashing library for C++
vector.hpp
Go to the documentation of this file.
1 /*! \file
2  * \brief Hashing of std::vector
3  */
4 
5 /* Copyright (c) 2016 Benjamin Pritchard <ben@bennyp.org>
6  * This file is part of the BPHash project, which is released
7  * under the BSD 3-clause license. See the LICENSE file for details
8  */
9 
10 #pragma once
11 
12 #include "bphash/Hasher.hpp"
14 #include <vector>
15 
16 namespace bphash {
17 
18 /*! \brief Hashing of std::vector */
19 template<typename T, typename Alloc>
20 typename std::enable_if<is_hashable<T>::value, void>::type
21 hash_object(const std::vector<T, Alloc> & v, Hasher & h)
22 {
23  h(hash_pointer(v.data(), v.size()));
24 }
25 
26 
27 /*! \brief Hashing of std::vector<bool> */
28 template<typename Alloc>
29 void hash_object(const std::vector<bool, Alloc> & v, Hasher & h)
30 {
31  // specialization of vector for bool is stored
32  // differently. So we have to go element by element
34 }
35 
36 
37 } // close namespace bphash
38 
Helpers for hashing STL containers.
std::enable_if< is_hashable< T >::value, void >::type hash_object(const std::array< T, N > &a, Hasher &h)
Hashing of std::array.
Definition: array.hpp:20
A class that hashes objects (header)
Class that is used to hash objects.
Definition: Hasher.hpp:78
std::enable_if< is_hashable< typename Cont::value_type >::value, void >::type hash_container_object(const Cont &cont, Hasher &hasher)
Helper for hashing STL containers.
PointerWrapper< T > hash_pointer(const T *ptr, size_t len=1)
Wrap a raw pointer so that it can be hashed.
Definition: Hasher.hpp:67