hash: Add support for arrays
There is now builtin support for stdplus::hash<> and
stdplus::hashMulti(...) hashing std::array<> and C array containers.
Change-Id: I111511fcd2c1627011b47cf3593cc9d63d752c1a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/hash.cpp b/test/hash.cpp
index d9bcd48..a49f1b4 100644
--- a/test/hash.cpp
+++ b/test/hash.cpp
@@ -1,5 +1,6 @@
#include <stdplus/hash.hpp>
+#include <array>
#include <string>
#include <tuple>
@@ -12,8 +13,10 @@
{
EXPECT_EQ(0, hashMulti());
EXPECT_EQ(2654435834, hashMulti(1, 2));
+ int s[4] = {1, 2, 3, 4};
+ std::array<uint16_t, 2> a = {3, 4};
std::tuple<std::string, int> t = {"s", 8};
- hashMulti(1, std::string("bacon"), nullptr, t);
+ hashMulti(1, std::string("bacon"), nullptr, s, a, t);
}
} // namespace stdplus
diff --git a/test/hash/array.cpp b/test/hash/array.cpp
new file mode 100644
index 0000000..73d2892
--- /dev/null
+++ b/test/hash/array.cpp
@@ -0,0 +1,14 @@
+#include <stdplus/hash/array.hpp>
+
+#include <gtest/gtest.h>
+
+namespace stdplus
+{
+
+TEST(HashTuple, Basic)
+{
+ std::array<std::string, 2> a{"bacon", "sound"};
+ std::hash<decltype(a)>{}(a);
+}
+
+} // namespace stdplus
diff --git a/test/meson.build b/test/meson.build
index ab788ff..1e15a0e 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -4,6 +4,7 @@
'handle/copyable': [stdplus_dep, gtest_main_dep],
'handle/managed': [stdplus_dep, gtest_main_dep],
'hash': [stdplus_dep, gtest_main_dep],
+ 'hash/array': [stdplus_dep, gtest_main_dep],
'hash/tuple': [stdplus_dep, gtest_main_dep],
'pinned': [stdplus_dep, gtest_main_dep],
'raw': [stdplus_dep, gmock_dep, gtest_main_dep],