# HG changeset patch
# User will <timwilloney@gmail.com>
# Date 1594150174 25200
#      Tue Jul 07 12:29:34 2020 -0700
# Node ID 95638bb7906ddfb39aea92fe3d20ec7149f180ed
# Parent  506ed4186b94eabca263fe1a8113406a6f8a7b6b
Add missing unordered_map template defaults (GH-3686)

diff --git a/Cython/Includes/libcpp/unordered_map.pxd b/Cython/Includes/libcpp/unordered_map.pxd
--- a/Cython/Includes/libcpp/unordered_map.pxd
+++ b/Cython/Includes/libcpp/unordered_map.pxd
@@ -1,7 +1,7 @@
 from .utility cimport pair
 
 cdef extern from "<unordered_map>" namespace "std" nogil:
-    cdef cppclass unordered_map[T, U]:
+    cdef cppclass unordered_map[T, U, HASH=*, PRED=*, ALLOCATOR=*]:
         ctypedef T key_type
         ctypedef U mapped_type
         ctypedef pair[const T, U] value_type
diff --git a/tests/run/cpp_stl_cpp11.pyx b/tests/run/cpp_stl_cpp11.pyx
--- a/tests/run/cpp_stl_cpp11.pyx
+++ b/tests/run/cpp_stl_cpp11.pyx
@@ -140,6 +140,11 @@
     return "pass"
 
 
+cdef extern from "cpp_unordered_map_helper.h":
+    cdef cppclass IntVectorHash:
+        pass
+
+
 def test_unordered_map_functionality():
     """
     >>> test_unordered_map_functionality()
@@ -153,6 +158,8 @@
         unordered_map[int, int] int_map2
         unordered_map[int, int*] intptr_map
         const int* intptr
+        unordered_map[vector[int], int, IntVectorHash] int_vector_map
+        vector[int] intvec
     assert int_map[1] == 2
     assert int_map.size() == 1
     assert int_map.erase(1) == 1 # returns number of elements erased
@@ -183,4 +190,12 @@
 
     intptr_map[0] = NULL
     intptr = intptr_map.const_at(0)
+
+    intvec = [1, 2]
+    int_vector_map[intvec] = 3
+    intvec = [4, 5]
+    int_vector_map[intvec] = 6
+    assert int_vector_map[intvec] == 6
+    intvec = [1, 2]
+    assert int_vector_map[intvec] == 3
     return "pass"
diff --git a/tests/run/cpp_unordered_map_helper.h b/tests/run/cpp_unordered_map_helper.h
new file mode 100644
--- /dev/null
+++ b/tests/run/cpp_unordered_map_helper.h
@@ -0,0 +1,13 @@
+#include <functional>
+#include <vector>
+
+struct IntVectorHash {
+  size_t operator()(const std::vector<int>& v) const {
+    std::hash<int> hasher;
+    size_t seed = 0;
+    for (int i : v) {
+      seed ^= hasher(i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+    }
+    return seed;
+  }
+};