name: Add std::hash<Name> to support unordered_map container

Change-Id: I1edda483340fc5a891b6ae3a9cc4baf39b859621
Refs: #2147
diff --git a/src/name.cpp b/src/name.cpp
index acad1d1..9090176 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -31,6 +31,8 @@
 #include "encoding/block.hpp"
 #include "encoding/encoding-buffer.hpp"
 
+#include <boost/functional/hash.hpp>
+
 namespace ndn {
 
 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Name>));
@@ -341,3 +343,13 @@
 }
 
 } // namespace ndn
+
+namespace std {
+size_t
+hash<ndn::Name>::operator()(const ndn::Name& name) const
+{
+  return boost::hash_range(name.wireEncode().wire(),
+                           name.wireEncode().wire() + name.wireEncode().size());
+}
+
+} // namespace std
diff --git a/src/name.hpp b/src/name.hpp
index f4b1411..1719e92 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -597,4 +597,14 @@
 
 } // namespace ndn
 
+namespace std {
+template<>
+struct hash<ndn::Name>
+{
+  size_t
+  operator()(const ndn::Name& name) const;
+};
+
+} // namespace std
+
 #endif