Просмотр исходного кода

Define std::hash specializations rather than bd::Hash

Bryan Drewery 11 лет назад
Родитель
Сommit
688882a37d
2 измененных файлов с 34 добавлено и 39 удалено
  1. 34 9
      src/chan.h
  2. 0 30
      src/eggdrop.h

+ 34 - 9
src/chan.h

@@ -8,9 +8,36 @@
 #ifndef _EGG_CHAN_H
 #define _EGG_CHAN_H
 
+#include <functional>
 #include <lib/bdlib/src/Array.h>
 #include <lib/bdlib/src/String.h>
 
+/* chan & global */
+enum flood_t {
+  FLOOD_PRIVMSG  = 0,
+  FLOOD_NOTICE   = 1,
+  FLOOD_CTCP     = 2,
+  FLOOD_NICK     = 3,
+  FLOOD_JOIN     = 4,
+  FLOOD_KICK     = 5,
+  FLOOD_DEOP     = 6,
+  FLOOD_PART     = 7,
+  FLOOD_BYTES    = 8
+};
+
+namespace std {
+  template<>
+  struct hash<flood_t>
+  {
+    inline size_t operator()(flood_t val) const {
+      return static_cast<size_t>(val);
+    }
+  };
+}
+
+#define FLOOD_CHAN_MAX   9
+#define FLOOD_GLOBAL_MAX 3
+
 typedef struct memstruct {
   struct memstruct *next;
   struct userrec *user;
@@ -31,18 +58,16 @@ typedef struct memstruct {
   bd::HashTable<flood_t, int>         *floodnum; // floodnum[FLOOD_PRIVMSG] = 1;
 } memberlist;
 
-#include <bdlib/src/bdlib.h>
-BDLIB_NS_BEGIN
-template<typename T>
-  struct Hash;
-
-template<>
-  struct Hash<memberlist*>
+namespace std {
+  template<>
+  struct hash<memberlist*>
   {
     // Use memory address
-    inline size_t operator()(memberlist* m) const { return reinterpret_cast<size_t>(m); }
+    inline size_t operator()(memberlist* m) const {
+      return reinterpret_cast<size_t>(m);
+    }
   };
-BDLIB_NS_END
+}
 
 #define CHAN_FLAG_OP	1
 #define CHAN_FLAG_VOICE 2

+ 0 - 30
src/eggdrop.h

@@ -125,36 +125,6 @@ enum {		/* TAKE A GUESS */
   ERROR
 };
 
-
-/* chan & global */
-enum flood_t {
-  FLOOD_PRIVMSG  = 0,
-  FLOOD_NOTICE   = 1,
-  FLOOD_CTCP     = 2,
-  FLOOD_NICK     = 3,
-  FLOOD_JOIN     = 4,
-  FLOOD_KICK     = 5,
-  FLOOD_DEOP     = 6,
-  FLOOD_PART     = 7,
-  FLOOD_BYTES    = 8
-};
-
-
-#include <bdlib/src/bdlib.h>
-BDLIB_NS_BEGIN
-template<typename T>
-  struct Hash;
-
-template<>
-  struct Hash<flood_t>
-  {
-    inline size_t operator()(flood_t val) const { return static_cast<size_t>(val); }
-  };
-BDLIB_NS_END
-
-#define FLOOD_CHAN_MAX   9
-#define FLOOD_GLOBAL_MAX 3
-
 #define FEATURE_1		BIT0
 #define FEATURE_2		BIT1