Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- using namespace std;
- template< class Key > class HashFunction
- {
- public:
- HashFunction( const Key & k );
- inline operator unsigned() const
- {
- return mHashCode;
- }
- size_t operator()(const Key &k) const;
- private:
- unsigned mHashCode;
- };
- template<> HashFunction< string >::HashFunction( const string & k )
- {
- mHashCode=std::hash<string>{}(k);
- }
- template <> size_t HashFunction< string >::operator()(const string &k) const
- {
- return mHashCode;
- }
- template< class Key, class Val, class Hash = HashFunction< Key > >
- class unordered_map_wrapper
- {
- public:
- unordered_map_wrapper();
- private:
- unordered_map<Key, Val, Hash> * mTable;
- };
- template< class Key, class Val, class Hash >
- unordered_map_wrapper< Key, Val, Hash >::unordered_map_wrapper()
- {
- mTable=new unordered_map<Key, Val, Hash>(5);
- }
- int main() {
- unordered_map_wrapper<string, unsigned> h;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement