template-hashtable-getters
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 108 33529a5c309fd85dad4adb0f672eaeb6493195ad
permissions -rw-r--r--
State as of now

* * *

diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -121,7 +121,8 @@ public:
    * @return PR_TRUE if the key exists. If key does not exist, pData is not
    *   modified.
    */
-  PRBool Get(KeyType aKey, UserDataType* pData) const
+  template<class Type>
+  PRBool Get(KeyType aKey, Type* pData) const
   {
     EntryType* ent = GetEntry(aKey);
 
@@ -135,12 +136,22 @@ public:
   }
 
   /**
+   * The following signature exists only to disambigate "nsnull" passed
+   * as pData.
+   */
+  PRBool Get(KeyType aKey, UserDataType* pData) const
+  {
+    return Get<UserDataType>(aKey, pData);
+  }
+
+  /**
    * put a new value for the associated key
    * @param aKey the key to put
    * @param aData the new data
    * @return always PR_TRUE, unless memory allocation failed
    */
-  PRBool Put(KeyType aKey, UserDataType aData)
+  template<class Type>
+  PRBool Put(KeyType aKey, Type aData)
   {
     EntryType* ent = PutEntry(aKey);