Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Reference

Header <boost/container_hash/hash.hpp>

For the full specification, see section 6.3 of the C++ Standard Library Technical Report and issue 6.18 of the Library Extension Technical Report Issues List (page 63).

Defines boost::hash, and helper functions.


  template<typename T> struct hash;

  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<> struct hash<>;
  template<typename T> struct hash<>;
  template<> struct hash<>;

  // Support functions (Boost extension).
  template<typename T>  (, );
  template<typename It>  (, );
  template<typename It>  (, , );

  // Overloadable hash implementation (Boost extension).
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
   ();
  template<typename T>  ();
  template<typename T,  N>  ();
  template<typename T,  N>  ();
  template<typename Ch, typename A> 
     ();
  template<typename A, typename B> 
     ();
  template<typename T, typename A> 
     ();
  template<typename T, typename A> 
     ();
  template<typename T, typename A> 
     ();
  template<typename K, typename C, typename A> 
     ();
  template<typename K, typename C, typename A> 
     ();
  template<typename K, typename T, typename C, typename A> 
     ();
  template<typename K, typename T, typename C, typename A> 
     ();
  template<typename T>  ();
   ();
  template<typename T,  N> 
     ();
  template<typename... T>  ();
}

Support functions (Boost extension).

  1. template<typename T>  ( seed,  v);

    Called repeatedly to incrementally create a hash value from several variables.

    Effects:

    Updates seed with a new hash value generated by combining it with the result of hash_value(v). Will always produce the same result for the same combination of seed and hash_value(v) during the single run of a program.

    Notes:

    hash_value is called without qualification, so that overloads can be found via ADL.

    This is an extension to TR1

    Forward declared in <boost/container_hash/hash_fwd.hpp>

    This hash function is not intended for general use, and isn't guaranteed to be equal during separate runs of a program - so please don't use it for any persistent storage or communication.

    Throws:

    Only throws if hash_value(T) throws. Strong exception safety, as long as hash_value(T) also has strong exception safety.
  2. template<typename It>  ( first,  last);
    template<typename It>  ( seed,  first,  last);

    Calculate the combined hash value of the elements of an iterator range.

    Effects:

    For the two argument overload:

    hash_combine(

    For the three arguments overload:

    hash_combine(

    Notes:

    hash_range is sensitive to the order of the elements so it wouldn't be appropriate to use this with an unordered container.

    This is an extension to TR1

    Forward declared in <boost/container_hash/hash_fwd.hpp>

    This hash function is not intended for general use, and isn't guaranteed to be equal during separate runs of a program - so please don't use it for any persistent storage or communication.

    Throws:

    Only throws if hash_value(std::iterator_traits<It>::value_type) throws. hash_range(std::size_t&, It, It) has basic exception safety as long as hash_value(std::iterator_traits<It>::value_type) has basic exception safety.

Overloadable hash implementation (Boost extension).

  1.  ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
     ( val);
    template<typename T>  ( val);
    template<typename T,  N>  ();
    template<typename T,  N>  ();
    template<typename Ch, typename A> 
       ( val);
    template<typename A, typename B> 
       ( val);
    template<typename T, typename A> 
       ( val);
    template<typename T, typename A> 
       ( val);
    template<typename T, typename A> 
       ( val);
    template<typename K, typename C, typename A> 
       ( val);
    template<typename K, typename C, typename A> 
       ( val);
    template<typename K, typename T, typename C, typename A> 
       ( val);
    template<typename K, typename T, typename C, typename A> 
       ( val);
    template<typename T>  ( val);
     ( val);
    template<typename T,  N> 
       ( val);
    template<typename... T>  ( val);

    Implementation of the hash function.

    Generally shouldn't be called directly by users, instead they should use boost::hash, boost::hash_range or boost::hash_combine which call hash_value without namespace qualification so that overloads for custom types are found via ADL.

    Notes:

    This is an extension to TR1

    This hash function is not intended for general use, and isn't guaranteed to be equal during separate runs of a program - so please don't use it for any persistent storage or communication.

    Throws:

    Only throws if a user supplied version of hash_value throws for an element of a container, or one of the types stored in a pair.

    Returns:

    Types Returns
    bool, char, signed char, unsigned char, wchar_t, char16_t, char32_t, short, unsigned short, int, unsigned int, long, unsigned long val
    long long, unsigned long long val when abs(val) <= std::numeric_limits<std::size_t>::max().
    float, double, long double An unspecified value, except that equal arguments shall yield the same result.
    T* An unspecified value, except that equal arguments shall yield the same result.
    T val[N], const T val[N] hash_range(val, val+N)
    std:basic_string<Ch, std::char_traits<Ch>, A>, std::vector<T, A>, std::list<T, A>, std::deque<T, A>, std::set<K, C, A>, std::multiset<K, C, A>, std::map<K, T, C, A>, std::multimap<K, T, C, A>, std::array<T, N> hash_range(val.begin(), val.end())
    std::pair<A, B>
    hash_combine(hash_combine(
    std::tuple<T...>
    hash_combine(hash_combine(
    std::complex<T> When T is a built in type and val.imag() == 0, the result is equal to hash_value(val.real()). Otherwise an unspecified value, except that equal arguments shall yield the same result.
    std::type_index val.hash_code()

PrevUpHomeNext