[cfe-commits] [libcxx] r159921 - /libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp

Howard Hinnant hhinnant at apple.com
Sun Jul 8 19:47:43 PDT 2012


Author: hhinnant
Date: Sun Jul  8 21:47:43 2012
New Revision: 159921

URL: http://llvm.org/viewvc/llvm-project?rev=159921&view=rev
Log:
Add test for self-referencing emplace test.

Added:
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp

Added: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp?rev=159921&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp Sun Jul  8 21:47:43 2012
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::vector<int> v;
+        v.reserve(3);
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+    }
+    {
+        std::vector<int> v;
+        v.reserve(4);
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}





More information about the cfe-commits mailing list