[libcxx] r242634 - Fix warnings in unordered_map

Eric Fiselier eric at efcs.ca
Sat Jul 18 20:16:48 PDT 2015


Author: ericwf
Date: Sat Jul 18 22:16:47 2015
New Revision: 242634

URL: http://llvm.org/viewvc/llvm-project?rev=242634&view=rev
Log:
Fix warnings in unordered_map

Added:
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp
Removed:
    libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/
Modified:
    libcxx/trunk/test/libcxx/test/config.py
    libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sat Jul 18 22:16:47 2015
@@ -579,6 +579,11 @@ class Configuration(object):
                 self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move')
                 self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions')
                 self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
+            std = self.get_lit_conf('std', None)
+            if std in ['c++98', 'c++03']:
+                # The '#define static_assert' provided by libc++ in C++03 mode
+                # causes an unused local typedef whenever it is used.
+                self.cxx.addCompileFlagIfSupported('-Wno-unused-local-typedef')
 
     def configure_sanitizer(self):
         san = self.get_lit_conf('use_sanitizer', '').strip()

Modified: libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp Sat Jul 18 22:16:47 2015
@@ -19,20 +19,18 @@
 #include <string>
 #include <cassert>
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
 {
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef C::const_iterator I;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.bucket_count() == 0);
     }
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef C::const_iterator I;
         typedef std::pair<int, std::string> P;
         P a[] =
         {
@@ -48,19 +46,16 @@ int main()
         const C c(std::begin(a), std::end(a));
         assert(c.bucket_count() >= 11);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef C::const_iterator I;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.bucket_count() == 0);
     }
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef C::const_iterator I;
         typedef std::pair<int, std::string> P;
         P a[] =
         {

Modified: libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp Sat Jul 18 22:16:47 2015
@@ -17,6 +17,7 @@
 // http://llvm.org/bugs/show_bug.cgi?id=16549
 
 #include <unordered_map>
+#include <cassert>
 
 struct Key {
   template <typename T> Key(const T&) {}
@@ -35,8 +36,12 @@ namespace std
 int
 main()
 {
-    std::unordered_map<Key, int>::iterator it =
-        std::unordered_map<Key, int>().find(Key(0));
-    std::pair<std::unordered_map<Key, int>::iterator, bool> result =
-        std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+    typedef std::unordered_map<Key, int> MapT;
+    typedef MapT::iterator Iter;
+    MapT map;
+    Iter it = map.find(Key(0));
+    assert(it == map.end());
+    std::pair<Iter, bool> result = map.insert(std::make_pair(Key(0), 42));
+    assert(result.second);
+    assert(result.first->second == 42);
 }

Modified: libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp Sat Jul 18 22:16:47 2015
@@ -20,6 +20,7 @@
 #include <cassert>
 #include <cfloat>
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -43,11 +44,10 @@ int main()
     }
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.load_factor() == 0);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
@@ -69,7 +69,6 @@ int main()
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.load_factor() == 0);
     }

Modified: libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp Sat Jul 18 22:16:47 2015
@@ -19,23 +19,20 @@
 #include <string>
 #include <cassert>
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
 {
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef C::const_iterator I;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.max_bucket_count() > 0);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef C::const_iterator I;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.max_bucket_count() > 0);
     }

Modified: libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp Sat Jul 18 22:16:47 2015
@@ -16,44 +16,37 @@
 // float max_load_factor() const;
 // void max_load_factor(float mlf);
 
-#ifdef _LIBCPP_DEBUG
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
 #include <unordered_map>
 #include <string>
 #include <cassert>
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
 {
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.max_load_factor() == 1);
     }
     {
         typedef std::unordered_map<int, std::string> C;
-        typedef std::pair<int, std::string> P;
         C c;
         assert(c.max_load_factor() == 1);
         c.max_load_factor(2.5);
         assert(c.max_load_factor() == 2.5);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef std::pair<int, std::string> P;
         const C c;
         assert(c.max_load_factor() == 1);
     }
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
                             min_allocator<std::pair<const int, std::string>>> C;
-        typedef std::pair<int, std::string> P;
         C c;
         assert(c.max_load_factor() == 1);
         c.max_load_factor(2.5);

Modified: libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp Sat Jul 18 22:16:47 2015
@@ -21,6 +21,7 @@
 
 #include "../../test_compare.h"
 #include "../../test_hash.h"
+#include "test_macros.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
@@ -31,7 +32,6 @@ int main()
         typedef test_compare<std::equal_to<int> > Compare;
         typedef test_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc(1));
         C c2(0, Hash(2), Compare(2), Alloc(2));
         c2.max_load_factor(2);
@@ -212,7 +212,6 @@ int main()
         typedef test_compare<std::equal_to<int> > Compare;
         typedef other_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc(1));
         C c2(0, Hash(2), Compare(2), Alloc(2));
         c2.max_load_factor(2);
@@ -387,13 +386,12 @@ int main()
         assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
         assert(c2.max_load_factor() == 1);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef test_hash<std::hash<int> > Hash;
         typedef test_compare<std::equal_to<int> > Compare;
         typedef min_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc());
         C c2(0, Hash(2), Compare(2), Alloc());
         c2.max_load_factor(2);

Modified: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp Sat Jul 18 22:16:47 2015
@@ -15,6 +15,8 @@
 
 // unordered_map(unordered_map&& u);
 
+// UNSUPPORTED: c++98, c++03
+
 #include <unordered_map>
 #include <string>
 #include <cassert>
@@ -27,23 +29,12 @@
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     {
         typedef std::unordered_map<int, std::string,
                                    test_hash<std::hash<int> >,
                                    test_compare<std::equal_to<int> >,
                                    test_allocator<std::pair<const int, std::string> >
                                    > C;
-        typedef std::pair<int, std::string> P;
-        P a[] =
-        {
-            P(1, "one"),
-            P(2, "two"),
-            P(3, "three"),
-            P(4, "four"),
-            P(1, "four"),
-            P(2, "four"),
-        };
         C c0(7,
             test_hash<std::hash<int> >(8),
             test_compare<std::equal_to<int> >(9),
@@ -105,23 +96,12 @@ int main()
 
         assert(c0.empty());
     }
-#if __cplusplus >= 201103L
     {
         typedef std::unordered_map<int, std::string,
                                    test_hash<std::hash<int> >,
                                    test_compare<std::equal_to<int> >,
                                    min_allocator<std::pair<const int, std::string> >
                                    > C;
-        typedef std::pair<int, std::string> P;
-        P a[] =
-        {
-            P(1, "one"),
-            P(2, "two"),
-            P(3, "three"),
-            P(4, "four"),
-            P(1, "four"),
-            P(2, "four"),
-        };
         C c0(7,
             test_hash<std::hash<int> >(8),
             test_compare<std::equal_to<int> >(9),
@@ -183,7 +163,6 @@ int main()
 
         assert(c0.empty());
     }
-#endif
 #if _LIBCPP_DEBUG >= 1
     {
         std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
@@ -195,5 +174,4 @@ int main()
         assert(s2.size() == 2);
     }
 #endif
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                               std::forward_as_tuple(6, 7));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == Emplaceable(6, 7));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                               std::forward_as_tuple(6, 7));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == Emplaceable(6, 7));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+                                                       std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+                                                       std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(3),
+                                       std::forward_as_tuple());
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+    template<typename T>
+    TemplateConstructor (const T&) {}
+};
+
+bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        c.erase(i);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if TEST_STD_VER >= 11
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        c.erase(i);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+#if TEST_STD_VER >= 14
+    {
+    //  This is LWG #2059
+        typedef TemplateConstructor T;
+        typedef std::unordered_map<T, int, Hash> C;
+        typedef C::iterator I;
+
+        C m;
+        T a{0};
+        I it = m.find(a);
+        if (it != m.end())
+            m.erase(it);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,178 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+#if TEST_STD_VER >= 11
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+    typename Unordered::const_iterator w = whole.begin();
+    typename Unordered::const_iterator p = part.begin();
+
+    while ( w != whole.end () && p != part.end()) {
+        if ( *w == *p )
+            p++;
+        w++;
+        }
+
+    return p == part.end();
+}
+#endif
+
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+#if TEST_STD_VER >= 11
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+    {
+    typedef std::unordered_map<int, int> C;
+    C m, m2;
+    for ( int i = 0; i < 10; ++i ) {
+        m[i] = i;
+        m2[i] = i;
+        }
+
+    C::iterator i = m2.begin();
+    int ctr = 0;
+    while (i != m2.end()) {
+        if (ctr++ % 2 == 0)
+            m2.erase(i++);
+        else
+            ++i;
+        }
+
+    assert (only_deletions (m, m2));
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 1);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(k == j);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(k == c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 1);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(k == j);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(k == c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5, 3);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(false);
+    }
+#endif
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,192 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// template <class M>
+//  pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
+// template <class M>
+//  pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
+// template <class M>
+//  iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
+// template <class M>
+//  iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
+
+#include <unordered_map>
+#include <cassert>
+#include <tuple>
+
+
+class Moveable
+{
+    Moveable(const Moveable&);
+    Moveable& operator=(const Moveable&);
+
+    int int_;
+    double double_;
+public:
+    Moveable() : int_(0), double_(0) {}
+    Moveable(int i, double d) : int_(i), double_(d) {}
+    Moveable(Moveable&& x)
+        : int_(x.int_), double_(x.double_)
+            {x.int_ = -1; x.double_ = -1;}
+    Moveable& operator=(Moveable&& x)
+        {int_ = x.int_; x.int_ = -1;
+         double_ = x.double_; x.double_ = -1;
+         return *this;
+        }
+
+    bool operator==(const Moveable& x) const
+        {return int_ == x.int_ && double_ == x.double_;}
+    bool operator<(const Moveable& x) const
+        {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+    size_t hash () const { return std::hash<int>()(int_) + std::hash<double>()(double_); }
+
+    int get() const {return int_;}
+    bool moved() const {return int_ == -1;}
+};
+
+namespace std {
+    template <> struct hash<Moveable> {
+        size_t operator () (const Moveable &m) const { return m.hash(); }
+    };
+}
+
+int main()
+{
+
+    { // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
+        typedef std::unordered_map<int, Moveable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace ( i, Moveable(i, (double) i));
+        assert(m.size() == 10);
+
+        for (int i=0; i < 20; i += 2)
+        {
+            Moveable mv(i+1, i+1);
+            r = m.insert_or_assign(i, std::move(mv));
+            assert(m.size() == 10);
+            assert(!r.second);                    // was not inserted
+            assert(mv.moved());                   // was moved from
+            assert(r.first->first == i);          // key
+            assert(r.first->second.get() == i+1); // value
+        }
+
+        Moveable mv1(5, 5.0);
+        r = m.insert_or_assign(-1, std::move(mv1));
+        assert(m.size() == 11);
+        assert(r.second);                    // was inserted
+        assert(mv1.moved());                 // was moved from
+        assert(r.first->first        == -1); // key
+        assert(r.first->second.get() == 5);  // value
+
+        Moveable mv2(9, 9.0);
+        r = m.insert_or_assign(3, std::move(mv2));
+        assert(m.size() == 12);
+        assert(r.second);                   // was inserted
+        assert(mv2.moved());                // was moved from
+        assert(r.first->first        == 3); // key
+        assert(r.first->second.get() == 9); // value
+
+        Moveable mv3(-1, 5.0);
+        r = m.insert_or_assign(117, std::move(mv3));
+        assert(m.size() == 13);
+        assert(r.second);                     // was inserted
+        assert(mv3.moved());                  // was moved from
+        assert(r.first->first        == 117); // key
+        assert(r.first->second.get() == -1);  // value
+    }
+    { // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
+        typedef std::unordered_map<Moveable, Moveable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+        assert(m.size() == 10);
+
+        Moveable mvkey1(2, 2.0);
+        Moveable mv1(4, 4.0);
+        r = m.insert_or_assign(std::move(mvkey1), std::move(mv1));
+        assert(m.size() == 10);
+        assert(!r.second);                  // was not inserted
+        assert(!mvkey1.moved());            // was not moved from
+        assert(mv1.moved());                // was moved from
+        assert(r.first->first == mvkey1);   // key
+        assert(r.first->second.get() == 4); // value
+
+        Moveable mvkey2(3, 3.0);
+        Moveable mv2(5, 5.0);
+        r = m.try_emplace(std::move(mvkey2), std::move(mv2));
+        assert(m.size() == 11);
+        assert(r.second);                   // was inserted
+        assert(mv2.moved());                // was moved from
+        assert(mvkey2.moved());             // was moved from
+        assert(r.first->first.get()  == 3); // key
+        assert(r.first->second.get() == 5); // value
+    }
+    { // iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
+        typedef std::unordered_map<int, Moveable> M;
+        M m;
+        M::iterator r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace ( i, Moveable(i, (double) i));
+        assert(m.size() == 10);
+        M::const_iterator it = m.find(2);
+
+        Moveable mv1(3, 3.0);
+        r = m.insert_or_assign(it, 2, std::move(mv1));
+        assert(m.size() == 10);
+        assert(mv1.moved());           // was moved from
+        assert(r->first        == 2);  // key
+        assert(r->second.get() == 3);  // value
+
+        Moveable mv2(5, 5.0);
+        r = m.insert_or_assign(it, 3, std::move(mv2));
+        assert(m.size() == 11);
+        assert(mv2.moved());           // was moved from
+        assert(r->first        == 3);  // key
+        assert(r->second.get() == 5);  // value
+    }
+    { // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
+        typedef std::unordered_map<Moveable, Moveable> M;
+        M m;
+        M::iterator r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+        assert(m.size() == 10);
+        M::const_iterator it = std::next(m.cbegin());
+
+        Moveable mvkey1(2, 2.0);
+        Moveable mv1(4, 4.0);
+        r = m.insert_or_assign(it, std::move(mvkey1), std::move(mv1));
+        assert(m.size() == 10);
+        assert(mv1.moved());          // was moved from
+        assert(!mvkey1.moved());      // was not moved from
+        assert(r->first == mvkey1);   // key
+        assert(r->second.get() == 4); // value
+
+        Moveable mvkey2(3, 3.0);
+        Moveable mv2(5, 5.0);
+        r = m.insert_or_assign(it, std::move(mvkey2), std::move(mv2));
+        assert(m.size() == 11);
+        assert(mv2.moved());           // was moved from
+        assert(mvkey2.moved());        // was moved from
+        assert(r->first.get()  == 3);  // key
+        assert(r->second.get() == 5);  // value
+    }
+
+}
\ No newline at end of file

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp?rev=242634&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp Sat Jul 18 22:16:47 2015
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// template <class... Args>
+//  pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
+// template <class... Args>
+//  pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
+// template <class... Args>
+//  iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+// template <class... Args>
+//  iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
+
+#include <__config>
+#include <unordered_map>
+#include <cassert>
+#include <tuple>
+
+class Moveable
+{
+    Moveable(const Moveable&);
+    Moveable& operator=(const Moveable&);
+
+    int int_;
+    double double_;
+public:
+    Moveable() : int_(0), double_(0) {}
+    Moveable(int i, double d) : int_(i), double_(d) {}
+    Moveable(Moveable&& x)
+        : int_(x.int_), double_(x.double_)
+            {x.int_ = -1; x.double_ = -1;}
+    Moveable& operator=(Moveable&& x)
+        {int_ = x.int_; x.int_ = -1;
+         double_ = x.double_; x.double_ = -1;
+         return *this;
+        }
+
+    bool operator==(const Moveable& x) const
+        {return int_ == x.int_ && double_ == x.double_;}
+    bool operator<(const Moveable& x) const
+        {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+    size_t hash () const { return std::hash<int>()(int_) + std::hash<double>()(double_); }
+
+    int get() const {return int_;}
+    bool moved() const {return int_ == -1;}
+};
+
+namespace std {
+    template <> struct hash<Moveable> {
+        size_t operator () (const Moveable &m) const { return m.hash(); }
+    };
+}
+
+int main()
+{
+
+    { // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
+        typedef std::unordered_map<int, Moveable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace (i, Moveable(i, (double) i));
+        assert(m.size() == 10);
+
+        Moveable mv1(3, 3.0);
+        for (int i=0; i < 20; i += 2)
+        {
+            r = m.try_emplace(i, std::move(mv1));
+            assert(m.size() == 10);
+            assert(!r.second);              // was not inserted
+            assert(!mv1.moved());           // was not moved from
+            assert(r.first->first == i);    // key
+        }
+
+        r = m.try_emplace(-1, std::move(mv1));
+        assert(m.size() == 11);
+        assert(r.second);                   // was inserted
+        assert(mv1.moved());                // was moved from
+        assert(r.first->first == -1);       // key
+        assert(r.first->second.get() == 3); // value
+
+        Moveable mv2(5, 3.0);
+        r = m.try_emplace(5, std::move(mv2));
+        assert(m.size() == 12);
+        assert(r.second);                   // was inserted
+        assert(mv2.moved());                // was moved from
+        assert(r.first->first == 5);        // key
+        assert(r.first->second.get() == 5); // value
+
+        Moveable mv3(-1, 3.0);
+        r = m.try_emplace(117, std::move(mv2));
+        assert(m.size() == 13);
+        assert(r.second);                    // was inserted
+        assert(mv2.moved());                 // was moved from
+        assert(r.first->first == 117);       // key
+        assert(r.first->second.get() == -1); // value
+    }
+
+    {  // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
+        typedef std::unordered_map<Moveable, Moveable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r;
+        for (int i = 0; i < 20; i += 2)
+            m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+        assert(m.size() == 10);
+
+        Moveable mvkey1(2, 2.0);
+        Moveable mv1(4, 4.0);
+        r = m.try_emplace(std::move(mvkey1), std::move(mv1));
+        assert(m.size() == 10);
+        assert(!r.second);                 // was not inserted
+        assert(!mv1.moved());              // was not moved from
+        assert(!mvkey1.moved());           // was not moved from
+        assert(r.first->first == mvkey1);  // key
+
+        Moveable mvkey2(3, 3.0);
+        r = m.try_emplace(std::move(mvkey2), std::move(mv1));
+        assert(m.size() == 11);
+        assert(r.second);                   // was inserted
+        assert(mv1.moved());                // was moved from
+        assert(mvkey2.moved());             // was moved from
+        assert(r.first->first.get()  == 3); // key
+        assert(r.first->second.get() == 4); // value
+    }
+
+    {  // iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
+        typedef std::unordered_map<int, Moveable> M;
+        M m;
+        M::iterator r;
+        for (int i = 0; i < 20; i += 2)
+            m.try_emplace ( i, Moveable(i, (double) i));
+        assert(m.size() == 10);
+        M::const_iterator it = m.find(2);
+
+        Moveable mv1(3, 3.0);
+        for (int i=0; i < 20; i += 2)
+        {
+            r = m.try_emplace(it, i, std::move(mv1));
+            assert(m.size() == 10);
+            assert(!mv1.moved());         // was not moved from
+            assert(r->first == i);        // key
+            assert(r->second.get() == i); // value
+        }
+
+        r = m.try_emplace(it, 3, std::move(mv1));
+        assert(m.size() == 11);
+        assert(mv1.moved());          // was moved from
+        assert(r->first == 3);        // key
+        assert(r->second.get() == 3); // value
+    }
+
+    {  // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
+        typedef std::unordered_map<Moveable, Moveable> M;
+        M m;
+        M::iterator r;
+        for ( int i = 0; i < 20; i += 2 )
+            m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+        assert(m.size() == 10);
+        M::const_iterator it = std::next(m.cbegin());
+
+        Moveable mvkey1(2, 2.0);
+        Moveable mv1(4, 4.0);
+        r = m.try_emplace(it, std::move(mvkey1), std::move(mv1));
+        assert(m.size() == 10);
+        assert(!mv1.moved());        // was not moved from
+        assert(!mvkey1.moved());     // was not moved from
+        assert(r->first == mvkey1);  // key
+
+        Moveable mvkey2(3, 3.0);
+        r = m.try_emplace(it, std::move(mvkey2), std::move(mv1));
+        assert(m.size() == 11);
+        assert(mv1.moved());          // was moved from
+        assert(mvkey2.moved());       // was moved from
+        assert(r->first.get()  == 3); // key
+        assert(r->second.get() == 4); // value
+    }
+}

Modified: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp?rev=242634&r1=242633&r2=242634&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp Sat Jul 18 22:16:47 2015
@@ -21,6 +21,7 @@
 
 #include "../../../test_compare.h"
 #include "../../../test_hash.h"
+#include "test_macros.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
@@ -31,7 +32,6 @@ int main()
         typedef test_compare<std::equal_to<int> > Compare;
         typedef test_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc(1));
         C c2(0, Hash(2), Compare(2), Alloc(2));
         c2.max_load_factor(2);
@@ -212,7 +212,6 @@ int main()
         typedef test_compare<std::equal_to<int> > Compare;
         typedef other_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc(1));
         C c2(0, Hash(2), Compare(2), Alloc(2));
         c2.max_load_factor(2);
@@ -387,13 +386,12 @@ int main()
         assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
         assert(c2.max_load_factor() == 1);
     }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
     {
         typedef test_hash<std::hash<int> > Hash;
         typedef test_compare<std::equal_to<int> > Compare;
         typedef min_allocator<std::pair<const int, std::string> > Alloc;
         typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
-        typedef std::pair<int, std::string> P;
         C c1(0, Hash(1), Compare(1), Alloc());
         C c2(0, Hash(2), Compare(2), Alloc());
         c2.max_load_factor(2);





More information about the cfe-commits mailing list