SkTDynamicHash: pick up GetKey(), Hash() from T by default.
This also has a somewhat obscure technical benefit: it removes the
requirement that GetKey() and Hash() must be functions with external
linkage, which is required when passing a function pointer to a
template. A future CL that's run into this problem and the obvious
simplification are about 50/50 why I'm sending this CL.
BUG=skia:
DIFFBASE= https://codereview.chromium.org/222343002/
R=bsalomon@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/222473002
git-svn-id: http://skia.googlecode.com/svn/trunk@14028 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/DynamicHashTest.cpp b/tests/DynamicHashTest.cpp
index bb9367b..b2da6f3 100644
--- a/tests/DynamicHashTest.cpp
+++ b/tests/DynamicHashTest.cpp
@@ -13,12 +13,13 @@
struct Entry {
int key;
double value;
+
+ static const int& GetKey(const Entry& entry) { return entry.key; }
+ static uint32_t Hash(const int& key) { return key; }
};
-const int& GetKey(const Entry& entry) { return entry.key; }
-uint32_t GetHash(const int& key) { return key; }
-class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash> {
+class Hash : public SkTDynamicHash<Entry, int> {
public:
Hash() : INHERITED() {}
@@ -27,7 +28,7 @@
int countCollisions(const int& key) const { return this->INHERITED::countCollisions(key); }
private:
- typedef SkTDynamicHash<Entry, int, GetKey, GetHash> INHERITED;
+ typedef SkTDynamicHash<Entry, int> INHERITED;
};
} // namespace