libzypp  10.5.0
Tr1hash.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_BASE_TR1HASH_H
00013 #define ZYPP_BASE_TR1HASH_H
00014 
00015 #include <iosfwd>
00016 #include <tr1/unordered_set>
00017 #include <tr1/unordered_map>
00018 
00019 #include "zypp/base/PtrTypes.h"
00020 
00028 #define ZYPP_DEFINE_ID_HASHABLE(C)           \
00029 namespace std { namespace tr1 {              \
00030   template<class _Tp> struct hash;           \
00031   template<> struct hash<C>                  \
00032   {                                          \
00033     size_t operator()( const C & __s ) const \
00034     { return __s.id(); }                     \
00035   };                                         \
00036 }}
00037 
00039 namespace zypp
00040 { 
00041 
00043   template<class _D>
00044   inline std::tr1::unordered_set<_D> * rwcowClone( const std::tr1::unordered_set<_D> * rhs )
00045   { return new std::tr1::unordered_set<_D>( *rhs ); }
00046 
00048   template<class _K, class _V>
00049   inline std::tr1::unordered_map<_K,_V> * rwcowClone( const std::tr1::unordered_map<_K,_V> * rhs )
00050   { return new std::tr1::unordered_map<_K,_V>( *rhs ); }
00051 
00053 } // namespace zypp
00055 #endif // ZYPP_BASE_TR1HASH_H