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>

Classes

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

Namespaces

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

Macros

#define ARMARX_IDENTITY(...)
 Expands to it's input.
 
#define ARMARX_OVERLOAD_STD_HASH(Type, Members)
 Overloads the std::hash template for Type.
 
#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().
 
#define ARMARX_STRIP_PARENTHESES(X)
 Strips the parentheses of an input.
 

Functions

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

Macro Definition Documentation

◆ ARMARX_IDENTITY

#define ARMARX_IDENTITY ( ...)
Value:
__VA_ARGS__

Expands to it's input.

◆ 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 \
{ \
} \
}; \
}
#define ARMARX_STRIP_PARENTHESES(X)
Strips the parentheses of an input.
Definition HashingUtil.h:41
std::size_t hash_all(const Ts &... ts)
Returns the hash of all parameters.
Definition HashingUtil.h:127
Definition Application.h:67

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!

◆ 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>))

◆ ARMARX_STRIP_PARENTHESES

#define ARMARX_STRIP_PARENTHESES ( X)
Value:
#define ARMARX_IDENTITY(...)
Expands to it's input.
Definition HashingUtil.h:36

Strips the parentheses of an input.

Function Documentation

◆ A() [1/5]

class A ( deque< T, A > )

Enables hashing of std::list.

◆ 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.