std C/C++ patch #6

David Scott Page page at cs.utexas.edu
Fri Apr 26 09:45:52 EDT 2002


Hi,

Inline functions have internal linkage, hence the inline methods of
hashmap.cc, such as bucket(), as instantiated in tools/lib/hashmapi.cc
have internal linkage and are not available to other library users at
link time.  Until the standard's export template instantiation model
is implemented, exported inlines need to stay in header files.

--
Scott Page

---------------------------- 8< ----------------------------------------
diff -Naur click-stdC++.5a/include/click/hashmap.cc click-stdC++.6/include/click/hashmap.cc
--- click-stdC++.5a/include/click/hashmap.cc	Wed Apr 24 16:39:20 2002
+++ click-stdC++.6/include/click/hashmap.cc	Fri Apr 26 13:22:04 2002
@@ -64,28 +64,6 @@
 }
 
 template <class K, class V>
-inline void
-HashMap<K, V>::resize(int i)
-{
-  while (i > _capacity) increase();
-}
-
-template <class K, class V>
-inline int
-HashMap<K, V>::bucket(const K &key) const
-{
-  int hc = hashcode(key);
-  int i =   hc       & (_capacity - 1);
-  int j = ((hc >> 6) & (_capacity - 1)) | 1;
-  
-  while (_e[i].k && !(_e[i].k == key))
-    i = (i + j) & (_capacity - 1);
-  
-  return i;
-}
-
-
-template <class K, class V>
 void
 HashMap<K, V>::increase()
 {
diff -Naur click-stdC++.5a/include/click/hashmap.hh click-stdC++.6/include/click/hashmap.hh
--- click-stdC++.5a/include/click/hashmap.hh	Wed Apr 24 16:39:20 2002
+++ click-stdC++.6/include/click/hashmap.hh	Fri Apr 26 12:50:51 2002
@@ -85,6 +85,20 @@
 
 
 template <class K, class V>
+inline int
+HashMap<K, V>::bucket(const K &key) const
+{
+  int hc = hashcode(key);
+  int i =   hc       & (_capacity - 1);
+  int j = ((hc >> 6) & (_capacity - 1)) | 1;
+  
+  while (_e[i].k && !(_e[i].k == key))
+    i = (i + j) & (_capacity - 1);
+  
+  return i;
+}
+
+template <class K, class V>
 inline const V &
 HashMap<K, V>::find(const K &key) const
 {
@@ -106,6 +120,13 @@
 {
   int i = bucket(key);
   return _e[i].k ? &_e[i].v : 0;
+}
+
+template <class K, class V>
+inline void
+HashMap<K, V>::resize(int i)
+{
+  while (i > _capacity) increase();
 }
 
 inline int



More information about the click mailing list