#ifndef CHILON_HASH_HPP
#define CHILON_HASH_HPP
#include <boost/functional/hash.hpp>
#include <vector>
#include <type_traits>
namespace chilon {
namespace detail {
struct hashable {};
template <class T, bool Custom>
struct hasher : T::hash_type {};
template <class T>
struct hasher<T, false> : std::hash<T> {};
}
template <class T>
struct hasher
: detail::hasher<T, std::is_base_of<detail::hashable, T>::value> {};
template <class T>
struct hasher< std::vector<T> > {
size_t operator()(std::vector<T> const& t) const {
return boost::hash_range(t.begin(), t.end());
}
};
template <class T>
size_t hash(T const& t) {
return hasher<T>()(t);
}
template <class H>
struct hashable : detail::hashable {
typedef H hash_type;
};
}
#endif