HashingUtil.h File Reference
#include <functional>
#include <boost/functional/hash.hpp>
#include <tuple>
#include <utility>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
+ Include dependency graph for HashingUtil.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hash< pair< A, B > >
 Enables hashing of std::pair. More...
 
struct  hash< tuple< Ts... > >
 Enables hashing of std::tuple. More...
 

Namespaces

 armarx
 This file offers overloads of toIce() and fromIce() functions for STL container types.
 
 std
 

Macros

#define ARMARX_IDENTITY(...)   __VA_ARGS__
 Expands to it's input. More...
 
#define ARMARX_OVERLOAD_STD_HASH(Type, Members)
 Overloads the std::hash template for Type. More...
 
#define ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE(TemplateArgs, Type)
 Overloads the std::hash template for a type Type with the member functions begin() and end(). More...
 
#define ARMARX_STRIP_PARENTHESES(X)   ARMARX_IDENTITY X
 Strips the parentheses of an input. More...
 

Functions

class A (deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
 Enables hashing of std::list. More...
 
class class A (list< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
 Enables hashing of std::set. More...
 
class C class A (map< K, V, C, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class K
 Enables hashing of std::multimap. More...
 
class A (multiset< T, C, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class K
 Enables hashing of std::map. More...
 
class A (set< T, C, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
 Enables hashing of std::multiset. More...
 
 ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE ((class T, class A),(vector< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
 Enables hashing of std::vector. More...
 
template<class T0 >
void do_hash (std::size_t &hashed, const T0 &t0)
 Combines the accumulated hash and the parameters hash. More...
 
template<class T0 , class... Ts>
void do_hash (std::size_t &hashed, const T0 &t0, const Ts &...ts)
 Combines the accumulated hash and the parameters hash. More...
 
template<class... Ts>
std::size_t hash_all (const Ts &...ts)
 Returns the hash of all parameters. More...
 

Macro Definition Documentation

◆ ARMARX_IDENTITY

#define ARMARX_IDENTITY (   ...)    __VA_ARGS__

Expands to it's input.

Definition at line 36 of file HashingUtil.h.

◆ ARMARX_OVERLOAD_STD_HASH

#define ARMARX_OVERLOAD_STD_HASH (   Type,
  Members 
)
Value:
namespace std\
{\
template<>\
struct hash< ARMARX_STRIP_PARENTHESES(Type) >\
{\
using argument_type = ARMARX_STRIP_PARENTHESES(Type);\
using result_type = std::size_t;\
result_type operator()(argument_type const& arg) const\
{\
}\
};\
}

Overloads the std::hash template for Type.

If the hash value of type foo depends on the members a and b the call has to be: ARMARX_OVERLOAD_STD_HASH((foo), (arg.a, arg.b)) The parentheses are required!

Definition at line 49 of file HashingUtil.h.

◆ ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE

#define ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE (   TemplateArgs,
  Type 
)
Value:
namespace std\
{\
template< ARMARX_STRIP_PARENTHESES(TemplateArgs) >\
struct hash< ARMARX_STRIP_PARENTHESES(Type) >\
{\
using argument_type = ARMARX_STRIP_PARENTHESES(Type);\
using result_type = std::size_t;\
result_type operator()(argument_type const& arg) const\
{\
return boost::hash_range(arg.begin(), arg.end());\
}\
};\
}

Overloads the std::hash template for a type Type with the member functions begin() and end().

If the type depends on some template parameters they can be passed as the first argument. The parentheses around both arguments are required!

examples: for vector<int, AllocatorType> : ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((), (vector<int, AllocatorType>)) for all vectors: ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T, class A), (vector<T, A>))

Definition at line 73 of file HashingUtil.h.

◆ ARMARX_STRIP_PARENTHESES

#define ARMARX_STRIP_PARENTHESES (   X)    ARMARX_IDENTITY X

Strips the parentheses of an input.

Definition at line 41 of file HashingUtil.h.

Function Documentation

◆ A() [1/5]

class A ( deque< T, A >  )

Enables hashing of std::list.

+ Here is the caller graph for this function:

◆ A() [2/5]

class class A ( list< T, A >  )

Enables hashing of std::set.

◆ A() [3/5]

class C class A ( map< K, V, C, A >  )

Enables hashing of std::multimap.

◆ A() [4/5]

class A ( multiset< T, C, A >  )

Enables hashing of std::map.

◆ A() [5/5]

class A ( set< T, C, A >  )

Enables hashing of std::multiset.

◆ ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE()

ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE ( (class T, class A ,
(vector< T, A >)   
)

Enables hashing of std::vector.

Enables hashing of std::deque.

ARMARX_STRIP_PARENTHESES
#define ARMARX_STRIP_PARENTHESES(X)
Strips the parentheses of an input.
Definition: HashingUtil.h:41
armarx::hash_all
std::size_t hash_all(const Ts &...ts)
Returns the hash of all parameters.
Definition: HashingUtil.h:122
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:8
std
Definition: Application.h:66