[libcxx] r224658 - Move test into test/std subdirectory.

Eric Fiselier eric at efcs.ca
Fri Dec 19 17:40:31 PST 2014


Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,516 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+//   int try_lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+    bool locked_;
+
+public:
+    L0() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = true;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L1
+{
+    bool locked_;
+
+public:
+    L1() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = false;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L2
+{
+    bool locked_;
+
+public:
+    L2() : locked_(false) {}
+
+    bool try_lock()
+    {
+        throw 1;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+int main()
+{
+    {
+        L0 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        assert(std::try_lock(l0, l1) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L1 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 3);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    m.lock();
+    std::lock_guard<std::mutex> lg(m, std::adopt_lock);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard& operator=(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    std::lock_guard<std::mutex> lg0(m0);
+    std::lock_guard<std::mutex> lg(m1);
+    lg = lg0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+    std::lock_guard<std::mutex> lg0(m);
+    std::lock_guard<std::mutex> lg(lg0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg = m;
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex>
+// class lock_guard
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::lock_guard<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m0);
+    std::shared_lock<std::shared_timed_mutex> lk1(m1);
+    lk1 = lk0;
+#else
+#   error
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m);
+    std::shared_lock<std::shared_timed_mutex> lk = lk0;
+#else
+#   error
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> ul;
+    assert(!ul.owns_lock());
+    assert(ul.mutex() == nullptr);
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m0);
+    std::shared_lock<std::shared_timed_mutex> lk1(m1);
+    lk1 = std::move(lk0);
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m);
+    std::shared_lock<std::shared_timed_mutex> lk = std::move(lk0);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit shared_lock(mutex_type& m);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::shared_lock<std::shared_timed_mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void g()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::shared_lock<std::shared_timed_mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0;
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+    m.lock_shared();
+    for (auto& t : v)
+        t = std::thread(g);
+    std::thread q(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock_shared();
+    for (auto& t : v)
+        t.join();
+    q.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, adopt_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+    m.lock();
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::adopt_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, defer_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//   shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//   shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, try_to_lock_t);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    while (true)
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        if (lk.owns_lock())
+            break;
+    }
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+    time_point t0 = Clock::now();
+    lk.lock();
+    time_point t1 = Clock::now();
+    assert(lk.owns_lock() == true);
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(25));  // within 25ms
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    lk.release();
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_called = false;
+
+struct mutex
+{
+    bool try_lock_shared()
+    {
+        try_lock_called = !try_lock_called;
+        return try_lock_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock() == true);
+    assert(try_lock_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock() == false);
+    assert(try_lock_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Rep, class Period>
+//   bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+    template <class Rep, class Period>
+        bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& rel_time)
+    {
+        assert(rel_time == ms(5));
+        try_lock_for_called = !try_lock_for_called;
+        return try_lock_for_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_for(ms(5)) == true);
+    assert(try_lock_for_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_for(ms(5)) == false);
+    assert(try_lock_for_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Clock, class Duration>
+//   bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+    template <class Clock, class Duration>
+        bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+    {
+        typedef std::chrono::milliseconds ms;
+        assert(Clock::now() - abs_time < ms(5));
+        try_lock_until_called = !try_lock_until_called;
+        return try_lock_until_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::chrono::steady_clock Clock;
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_until(Clock::now()) == true);
+    assert(try_lock_until_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_until(Clock::now()) == false);
+    assert(try_lock_until_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void unlock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool unlock_called = false;
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {unlock_called = true;}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m);
+    lk.unlock();
+    assert(unlock_called == true);
+    assert(lk.owns_lock() == false);
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+    lk.release();
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void swap(shared_lock& u) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk1(m);
+    std::shared_lock<mutex> lk2;
+    lk1.swap(lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+    static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Mutex>
+//   void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk1(m);
+    std::shared_lock<mutex> lk2;
+    swap(lk1, lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+    static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type* release() noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    static int lock_count;
+    static int unlock_count;
+    void lock_shared() {++lock_count;}
+    void unlock_shared() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    assert(lk.release() == &m);
+    assert(lk.mutex() == nullptr);
+    assert(lk.owns_lock() == false);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    static_assert(noexcept(lk.release()), "release must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type *mutex() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(lk0.mutex() == nullptr);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(lk1.mutex() == &m);
+    lk1.unlock();
+    assert(lk1.mutex() == &m);
+    static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit operator bool() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(static_cast<bool>(lk0) == false);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(static_cast<bool>(lk1) == true);
+    lk1.unlock();
+    assert(static_cast<bool>(lk1) == false);
+    static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool owns_lock() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(lk0.owns_lock() == false);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(lk1.owns_lock() == true);
+    lk1.unlock();
+    assert(lk1.owns_lock() == false);
+    static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex>
+// class shared_lock
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <shared_mutex>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::shared_lock<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = lk0;
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = lk0;
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::unique_lock<std::mutex> ul;
+    assert(!ul.owns_lock());
+    assert(ul.mutex() == nullptr);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = std::move(lk0);
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = std::move(lk0);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit unique_lock(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::unique_lock<std::mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    m.lock();
+    std::unique_lock<std::mutex> lk(m, std::adopt_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, defer_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == false);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//   unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//   unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, try_to_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    while (true)
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        if (lk.owns_lock())
+            break;
+    }
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    time_point t0 = Clock::now();
+    lk.lock();
+    time_point t1 = Clock::now();
+    assert(lk.owns_lock() == true);
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(25));  // within 25ms
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    lk.release();
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool try_lock();
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_called = false;
+
+struct mutex
+{
+    bool try_lock()
+    {
+        try_lock_called = !try_lock_called;
+        return try_lock_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock() == true);
+    assert(try_lock_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock() == false);
+    assert(try_lock_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+//   bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+    template <class Rep, class Period>
+        bool try_lock_for(const std::chrono::duration<Rep, Period>& rel_time)
+    {
+        assert(rel_time == ms(5));
+        try_lock_for_called = !try_lock_for_called;
+        return try_lock_for_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_for(ms(5)) == true);
+    assert(try_lock_for_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_for(ms(5)) == false);
+    assert(try_lock_for_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+//   bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+    template <class Clock, class Duration>
+        bool try_lock_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+    {
+        typedef std::chrono::milliseconds ms;
+        assert(Clock::now() - abs_time < ms(5));
+        try_lock_until_called = !try_lock_until_called;
+        return try_lock_until_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    typedef std::chrono::steady_clock Clock;
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_until(Clock::now()) == true);
+    assert(try_lock_until_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_until(Clock::now()) == false);
+    assert(try_lock_until_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void unlock();
+
+#include <mutex>
+#include <cassert>
+
+bool unlock_called = false;
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {unlock_called = true;}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    lk.unlock();
+    assert(unlock_called == true);
+    assert(lk.owns_lock() == false);
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+    lk.release();
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    lk1.swap(lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Mutex>
+//   void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    swap(lk1, lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type* release() noexcept;
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    static int lock_count;
+    static int unlock_count;
+    void lock() {++lock_count;}
+    void unlock() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    assert(lk.release() == &m);
+    assert(lk.mutex() == nullptr);
+    assert(lk.owns_lock() == false);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type *mutex() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.mutex() == nullptr);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.mutex() == &m);
+    lk1.unlock();
+    assert(lk1.mutex() == &m);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(static_cast<bool>(lk0) == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(static_cast<bool>(lk1) == true);
+    lk1.unlock();
+    assert(static_cast<bool>(lk1) == false);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool owns_lock() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.owns_lock() == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.owns_lock() == true);
+    lk1.unlock();
+    assert(lk1.owns_lock() == false);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex>
+// class unique_lock
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::unique_lock<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// struct defer_lock_t {};
+// struct try_to_lock_t {};
+// struct adopt_lock_t {};
+//
+// constexpr defer_lock_t  defer_lock{};
+// constexpr try_to_lock_t try_to_lock{};
+// constexpr adopt_lock_t  adopt_lock{};
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    typedef std::defer_lock_t T1;
+    typedef std::try_to_lock_t T2;
+    typedef std::adopt_lock_t T3;
+
+    T1 t1 = std::defer_lock;
+    T2 t2 = std::try_to_lock;
+    T3 t3 = std::adopt_lock;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex& operator=(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    m1 = m0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1(m0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1;
+    m1 = m0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1(m0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::recursive_mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m0;
+    std::shared_timed_mutex m1;
+    m1 = m0;
+#else
+#   error
+#endif
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m0;
+    std::shared_timed_mutex m1(m0);
+#else
+#   error
+#endif
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex();
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+#endif
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock_shared();
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void g()
+{
+    time_point t0 = Clock::now();
+    m.lock_shared();
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0;
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+    m.lock_shared();
+    for (auto& t : v)
+        t = std::thread(g);
+    std::thread q(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock_shared();
+    for (auto& t : v)
+        t.join();
+    q.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock_shared());
+    assert(!m.try_lock_shared());
+    assert(!m.try_lock_shared());
+    while(!m.try_lock_shared())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex& operator=(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1;
+    m1 = m0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1(m0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1;
+    m1 = m0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1(m0);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,208 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <mutex>
+
+// struct once_flag;
+
+// template<class Callable, class ...Args>
+//   void call_once(once_flag& flag, Callable func, Args&&... args);
+
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+std::once_flag flg0;
+
+int init0_called = 0;
+
+void init0()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init0_called;
+}
+
+void f0()
+{
+    std::call_once(flg0, init0);
+}
+
+std::once_flag flg3;
+
+int init3_called = 0;
+int init3_completed = 0;
+
+void init3()
+{
+    ++init3_called;
+    std::this_thread::sleep_for(ms(250));
+    if (init3_called == 1)
+        throw 1;
+    ++init3_completed;
+}
+
+void f3()
+{
+    try
+    {
+        std::call_once(flg3, init3);
+    }
+    catch (...)
+    {
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+struct init1
+{
+    static int called;
+
+    void operator()(int i) {called += i;}
+};
+
+int init1::called = 0;
+
+std::once_flag flg1;
+
+void f1()
+{
+    std::call_once(flg1, init1(), 1);
+}
+
+struct init2
+{
+    static int called;
+
+    void operator()(int i, int j) const {called += i + j;}
+};
+
+int init2::called = 0;
+
+std::once_flag flg2;
+
+void f2()
+{
+    std::call_once(flg2, init2(), 2, 3);
+    std::call_once(flg2, init2(), 4, 5);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+std::once_flag flg41;
+std::once_flag flg42;
+
+int init41_called = 0;
+int init42_called = 0;
+
+void init42();
+
+void init41()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init41_called;
+}
+
+void init42()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init42_called;
+}
+
+void f41()
+{
+    std::call_once(flg41, init41);
+    std::call_once(flg42, init42);
+}
+
+void f42()
+{
+    std::call_once(flg42, init42);
+    std::call_once(flg41, init41);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+#if !defined(__clang__)
+   // GCC 4.8 complains about the following being private
+public:
+    MoveOnly(const MoveOnly&)
+    {
+    }
+#else
+    MoveOnly(const MoveOnly&);
+#endif
+public:
+    MoveOnly() {}
+    MoveOnly(MoveOnly&&) {}
+
+    void operator()(MoveOnly&&)
+    {
+    }
+};
+
+#endif
+
+int main()
+{
+    // check basic functionality
+    {
+        std::thread t0(f0);
+        std::thread t1(f0);
+        t0.join();
+        t1.join();
+        assert(init0_called == 1);
+    }
+    // check basic exception safety
+    {
+        std::thread t0(f3);
+        std::thread t1(f3);
+        t0.join();
+        t1.join();
+        assert(init3_called == 2);
+        assert(init3_completed == 1);
+    }
+    // check deadlock avoidance
+    {
+        std::thread t0(f41);
+        std::thread t1(f42);
+        t0.join();
+        t1.join();
+        assert(init41_called == 1);
+        assert(init42_called == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    // check functors with 1 arg
+    {
+        std::thread t0(f1);
+        std::thread t1(f1);
+        t0.join();
+        t1.join();
+        assert(init1::called == 1);
+    }
+    // check functors with 2 args
+    {
+        std::thread t0(f2);
+        std::thread t1(f2);
+        t0.join();
+        t1.join();
+        assert(init2::called == 5);
+    }
+    {
+        std::once_flag f;
+        std::call_once(f, MoveOnly(), MoveOnly());
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag& operator=(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2;
+    f2 = f;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2(f);
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// constexpr once_flag() noexcept;
+
+#include <mutex>
+
+int main()
+{
+    {
+    std::once_flag f;
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::once_flag f;
+    }
+#endif
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/version.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+#include <mutex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void swap(thread& x, thread& y);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        swap(t0, t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0(G());
+        std::thread t1;
+        t1 = t0;
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// NOTE: std::terminate is called so the destructors are not invoked and the
+// memory is not freed. This will cause ASAN to fail.
+// XFAIL: asan
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::set_terminate(f1);
+    {
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t0 = std::move(t1);
+        assert(false);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+// UNSUPPORTED: asan, msan
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_one == 0)
+        throw std::bad_alloc();
+    --throw_one;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+bool f_run = false;
+
+void f()
+{
+    f_run = true;
+}
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+public:
+    MoveOnly() {}
+    MoveOnly(MoveOnly&&) {}
+
+    void operator()(MoveOnly&&)
+    {
+    }
+};
+
+#endif
+
+int main()
+{
+    {
+        std::thread t(f);
+        t.join();
+        assert(f_run == true);
+    }
+    f_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            std::thread t(f);
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(!f_run);
+        }
+    }
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    G::op_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+            std::thread t((G()));
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t(G(), 5, 5.5);
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    {
+        std::thread t = std::thread(MoveOnly(), MoveOnly());
+        t.join();
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+//     template <class _Fp, class ..._Args,
+//         explicit thread(_Fp&& __f, _Args&&... __args);
+//  This constructor shall not participate in overload resolution 
+//       if decay<F>::type is the same type as std::thread.
+
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    volatile std::thread t1;
+    std::thread t2 ( t1, 1, 2.0 );
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(const thread&) = delete;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = t0;
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread t;
+    assert(t.get_id() == std::thread::id());
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// ~thread();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_terminate(f1);
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+    }
+    assert(false);
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id& operator=(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert(id1 == id0);
+    id1 = std::this_thread::get_id();
+    assert(id1 != id0);
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1 = id0;
+    assert(id1 == id0);
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id;
+    assert(id == std::thread::id());
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// bool operator==(thread::id x, thread::id y);
+// bool operator!=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert( (id1 == id0));
+    assert(!(id1 != id0));
+    id1 = std::this_thread::get_id();
+    assert(!(id1 == id0));
+    assert( (id1 != id0));
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// bool operator< (thread::id x, thread::id y);
+// bool operator<=(thread::id x, thread::id y);
+// bool operator> (thread::id x, thread::id y);
+// bool operator>=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    assert(!(id0 <  id1));
+    assert( (id0 <= id1));
+    assert(!(id0 >  id1));
+    assert( (id0 >= id1));
+    assert(!(id0 == id2));
+    if (id0 < id2) {
+      assert( (id0 <= id2));
+      assert(!(id0 >  id2));
+      assert(!(id0 >= id2));
+    } else {
+      assert(!(id0 <= id2));
+      assert( (id0 >  id2));
+      assert( (id0 >= id2));
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+#include <thread>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0 = std::this_thread::get_id();
+    std::ostringstream os;
+    os << id0;
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    typedef std::hash<std::thread::id> H;
+    H h;
+    assert(h(id1) != h(id2));
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void detach();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.detach();
+        assert(!t0.joinable());
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+        assert(G::op_run);
+        assert(G::n_alive == 0);
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// id get_id() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        assert(t0.get_id() != id1);
+        assert(t1.get_id() == std::thread::id());
+        t0.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void join();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// bool joinable() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        pthread_t pid = t0.native_handle();
+        assert(pid != 0);
+        t0.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void swap(thread& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        t0.swap(t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// unsigned hardware_concurrency();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    assert(std::thread::hardware_concurrency() > 0);
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+// {
+// public:
+//     typedef pthread_t native_handle_type;
+//     ...
+// };
+
+#include <thread>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// thread::id this_thread::get_id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id = std::this_thread::get_id();
+    assert(id != std::thread::id());
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// template <class Rep, class Period>
+//   void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+#include <signal.h>
+#include <sys/time.h>
+
+int main()
+{
+    int ec;
+    struct sigaction action;
+    action.sa_handler = [](int) {};
+    sigemptyset(&action.sa_mask);
+    action.sa_flags = 0;
+
+    ec = sigaction(SIGALRM, &action, nullptr);
+    assert(!ec);
+
+    struct itimerval it;
+    it.it_interval = { 0 };
+    it.it_value.tv_sec = 0;
+    it.it_value.tv_usec = 250000;
+    // This will result in a SIGALRM getting fired resulting in the nanosleep
+    // inside sleep_for getting EINTR.
+    ec = setitimer(ITIMER_REAL, &it, nullptr);
+    assert(!ec);
+
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_for(ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = 5 * ms / 100;
+    // The time slept is within 5% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// template <class Clock, class Duration>
+//   void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_until(t0 + ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = 5 * ms / 100;
+    // The time slept is within 5% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}

Added: libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+// void this_thread::yield();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::this_thread::yield();
+}

Added: libcxx/trunk/test/std/thread/thread.threads/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.threads/version.pass.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.threads/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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: libcpp-has-no-threads
+
+// <thread>
+
+#include <thread>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(OuterA2&& outerAlloc,
+//                            const InnerAllocs& ...innerAllocs);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A1<int> a3(3);
+        A a(a3);
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+    }
+    A1<int>::copy_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(3));
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+    }
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(4), A2<int>(5));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A3<int>::copy_called = false;
+    A3<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(4), A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
+//                                                           InnerAllocs...>& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A3<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
+//                                                     InnerAllocs...>&& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == true);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor();
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == false);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n, const_void_pointer hint);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)0);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>, A3<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)20);
+        assert(A2<int>::allocate_called == true);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T, class... Args> void construct(T* p, Args&&... args);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct B
+{
+    static bool constructed;
+
+    typedef A1<B> allocator_type;
+
+    explicit B(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 5);
+        assert(i == 6);
+        constructed = true;
+    }
+};
+
+bool B::constructed = false;
+
+struct C
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<C>> allocator_type;
+
+    explicit C(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 7);
+        assert(i == 8);
+        constructed = true;
+    }
+};
+
+bool C::constructed = false;
+
+struct D
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<D>> allocator_type;
+
+    explicit D(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 3);
+        constructed = true;
+    }
+};
+
+bool D::constructed = false;
+
+struct E
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A1<E>> allocator_type;
+
+    explicit E(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool E::constructed = false;
+
+struct F
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<F>> allocator_type;
+
+    explicit F(int i, int j)
+    {
+        assert(i == 1);
+        assert(j == 2);
+    }
+
+    explicit F(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool F::constructed = false;
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<std::string>> A;
+        A a;
+        char buf[100];
+        typedef std::string S;
+        S* s = (S*)buf;
+        a.construct(s, 4, 'c');
+        assert(*s == "cccc");
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a(A1<B>(5));
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        a.construct(s, 6);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<C>> A;
+        A a(A1<int>(5), A2<C>(7));
+        char buf[100];
+        typedef C S;
+        S* s = (S*)buf;
+        a.construct(s, 8);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<D>> A;
+        A a(A1<int>(5), A2<D>(3));
+        char buf[100];
+        typedef D S;
+        S* s = (S*)buf;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<E>, A2<E>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<E>> A;
+        A a(K(), A1<E>(50));
+        char buf[100];
+        typedef E S;
+        S* s = (S*)buf;
+        A3<E>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        assert(A3<E>::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<F>, A2<F>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<F>> A;
+        A a(K(), A1<F>(50));
+        char buf[100];
+        typedef F S;
+        S* s = (S*)buf;
+        A3<F>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(!S::constructed);
+        assert(A3<F>::constructed);
+        s->~S();
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// void deallocate(pointer p, size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T> void destroy(T* p);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+struct B
+{
+    static bool constructed;
+
+    B() {constructed = true;}
+    ~B() {constructed = false;}
+};
+
+bool B::constructed = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        a.construct(s);
+        assert(S::constructed);
+        a.destroy(s);
+        assert(!S::constructed);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<B>, A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        assert(!A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.construct(s);
+        assert(S::constructed);
+        assert(A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.destroy(s);
+        assert(!S::constructed);
+        assert(A3<S>::constructed);
+        assert(A3<S>::destroy_called);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// inner_allocator_type& inner_allocator();
+// const inner_allocator_type& inner_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.inner_allocator() == a);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(6)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(6), A3<int>(8))));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// size_type max_size() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        const A a(A1<int>(100));
+        assert(a.max_size() == 100);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        const A a(A1<int>(20), A2<int>());
+        assert(a.max_size() == 20);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        const A a(A1<int>(200), A2<int>(), A3<int>());
+        assert(a.max_size() == 200);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// outer_allocator_type& outer_allocator();
+// const outer_allocator_type& outer_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor select_on_container_copy_construction() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 3);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<int>> A;
+        A a1(A3<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == -1);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(1), A2<int>(2), A3<int>(3));
+        assert(a1.outer_allocator().id() == 1);
+        assert(a1.inner_allocator().outer_allocator().id() == 2);
+        assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 1);
+        assert(a2.inner_allocator().outer_allocator().id() == 2);
+        assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <scoped_allocator>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc                        allocator_type;
+//     typedef typename allocator_type::value_type
+//                                          value_type;
+// 
+//     typedef Alloc::pointer | value_type* pointer;
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//                                          const_pointer;
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+     typename std::allocator_traits<Alloc>::pointer        vp;
+     typename std::allocator_traits<Alloc>::const_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+     typename std::allocator_traits<Alloc>::void_pointer        vp;
+     typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+    test_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+    test_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+    test_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
+
+    test_void_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+    test_void_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+    test_void_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();   
+}
+#else
+int main() {}
+#endif

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below inner_allocator_type;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A1<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>, A3<int>>>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_copy_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_copy_assignment,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_move_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_swap;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_swap,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+//     bool
+//     operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+//                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+// 
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+//     bool
+//     operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+//                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a1(A1<int>(4), A2<int>(5));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A a2(A1<int>(4), A2<int>(5), A3<int>(5));
+        assert(a2 != a1);
+        assert(!(a2 == a1));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/allocator.adaptor/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/allocator.adaptor/types.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+//     : public OuterAlloc
+// {
+// public:
+//     typedef OuterAlloc outer_allocator_type;
+//     typedef typename OuterTraits::size_type size_type;
+//     typedef typename OuterTraits::difference_type difference_type;
+//     typedef typename OuterTraits::pointer pointer;
+//     typedef typename OuterTraits::const_pointer const_pointer;
+//     typedef typename OuterTraits::void_pointer void_pointer;
+//     typedef typename OuterTraits::const_void_pointer const_void_pointer;
+// };
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_base_of<
+        A1<int>,
+        std::scoped_allocator_adaptor<A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
+        A1<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::size_type,
+        std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::difference_type,
+        std::ptrdiff_t>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+    static_assert((std::is_base_of<
+        A2<int>,
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
+        A2<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
+        unsigned>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
+        int>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/date.time/tested_elsewhere.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/date.time/tested_elsewhere.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/date.time/tested_elsewhere.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/date.time/tested_elsewhere.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    std::clock_t c = 0;
+    std::size_t s = 0;
+    std::time_t t = 0;
+    std::tm tm = {0};
+    char str[3];
+    static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+    static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::strftime(str,s,"",&tm)), std::size_t>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// divides
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::divides<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(36, 4) == 9);
+#if _LIBCPP_STD_VER > 11
+    typedef std::divides<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 4) == 9);
+    assert(f2(36.0, 4) == 9);
+    assert(f2(18, 4.0) == 4.5); // exact in binary
+
+    constexpr int foo = std::divides<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::divides<> () (3.0, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// minus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::minus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 1);
+#if _LIBCPP_STD_VER > 11
+    typedef std::minus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 1);
+    assert(f2(3.0, 2) == 1);
+    assert(f2(3, 2.5) == 0.5);
+
+    constexpr int foo = std::minus<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::minus<> () (3.0, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// modulus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::modulus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(36, 8) == 4);
+#if _LIBCPP_STD_VER > 11
+    typedef std::modulus<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 8) == 4);
+    assert(f2(36L, 8) == 4);
+    assert(f2(36, 8L) == 4);
+
+    constexpr int foo = std::modulus<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::modulus<> () (3L, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// multiplies
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::multiplies<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 6);
+#if _LIBCPP_STD_VER > 11
+    typedef std::multiplies<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 6);
+    assert(f2(3.0, 2) == 6);
+    assert(f2(3, 2.5) == 7.5); // exact in binary
+
+    constexpr int foo = std::multiplies<int> () (3, 2);
+    static_assert ( foo == 6, "" );
+
+    constexpr int bar = std::multiplies<> () (3.0, 2);
+    static_assert ( bar == 6, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::negate<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    assert(f(36) == -36);
+#if _LIBCPP_STD_VER > 11
+    typedef std::negate<> F2;
+    const F2 f2 = F2();
+    assert(f2(36) == -36);
+    assert(f2(36L) == -36);
+    assert(f2(36.0) == -36);
+
+    constexpr int foo = std::negate<int> () (3);
+    static_assert ( foo == -3, "" );
+
+    constexpr int bar = std::negate<> () (3.0);
+    static_assert ( bar == -3, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// plus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::plus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 5);
+#if _LIBCPP_STD_VER > 11
+    typedef std::plus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 5);
+    assert(f2(3.0, 2) == 5);
+    assert(f2(3, 2.5) == 5.5);
+    
+    constexpr int foo = std::plus<int> () (3, 2);
+    static_assert ( foo == 5, "" );
+
+    constexpr int bar = std::plus<> () (3.0, 2);
+    static_assert ( bar == 5, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::plus<int>>::value, "" );
+    static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::plus<void>>::value, "" );
+    static_assert (  is_transparent<std::plus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::minus<int>>::value, "" );
+    static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::minus<void>>::value, "" );
+    static_assert (  is_transparent<std::minus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
+    static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
+    static_assert (  is_transparent<std::multiplies<void>>::value, "" );
+    static_assert (  is_transparent<std::multiplies<>>::value, "" );
+
+    static_assert ( !is_transparent<std::divides<int>>::value, "" );
+    static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
+    static_assert (  is_transparent<std::divides<void>>::value, "" );
+    static_assert (  is_transparent<std::divides<>>::value, "" );
+
+    static_assert ( !is_transparent<std::modulus<int>>::value, "" );
+    static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::modulus<void>>::value, "" );
+    static_assert (  is_transparent<std::modulus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::negate<int>>::value, "" );
+    static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
+    static_assert (  is_transparent<std::negate<void>>::value, "" );
+    static_assert (  is_transparent<std::negate<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16385
+
+#include <functional>
+#include <cmath>
+#include <cassert>
+
+float _pow(float a, float b)
+{
+    return std::pow(a, b);
+}
+
+int main()
+{
+    std::function<float(float, float)> fnc = _pow;
+    auto task = std::bind(fnc, 2.f, 4.f);
+    auto task2(task);
+    assert(task() == 16);
+    assert(task2() == 16);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+template <class R, class F>
+void
+test(F f, R expected)
+{
+    assert(f() == expected);
+}
+
+template <class R, class F>
+void
+test_const(const F& f, R expected)
+{
+    assert(f() == expected);
+}
+
+int f() {return 1;}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+    int operator()() const {return 5;}
+};
+
+int main()
+{
+    test(std::bind(f), 1);
+    test(std::bind(&f), 1);
+    test(std::bind(A_int_0()), 4);
+    test_const(std::bind(A_int_0()), 5);
+
+    test(std::bind<int>(f), 1);
+    test(std::bind<int>(&f), 1);
+    test(std::bind<int>(A_int_0()), 4);
+    test_const(std::bind<int>(A_int_0()), 5);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    int i = 2;
+    std::bind(f_void_1, _1)(i);
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    {
+    int i = 2;
+    std::bind(f_void_1, i)();
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    int i = 3;
+    std::bind(fp, _1)(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    {
+    void (*fp)(int) = f_void_1;
+    int i = 3;
+    std::bind(fp, i)();
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    int i = 4;
+    std::bind(a0, _1)(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    {
+    A_void_1 a0;
+    int i = 4;
+    std::bind(a0, i)();
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    A_void_1 a;
+    std::bind(fp, _1)(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, _1)(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    A_void_1 a;
+    std::bind(fp, a)();
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, ap)();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    A_void_1 a;
+    std::bind(fp, _1)(a);
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, _1)(ap);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    A_void_1 a;
+    std::bind(fp, a)();
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, ap)();
+    assert(count == save_count+2);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    using namespace std::placeholders;
+    // function
+    {
+    int i = 2;
+    assert(std::bind(f_int_1, _1)(i) == 3);
+    assert(std::bind(f_int_1, i)() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    int i = 3;
+    assert(std::bind(fp, _1)(i) == 4);
+    assert(std::bind(fp, i)() == 4);
+    }
+    // functor
+    {
+    int i = 4;
+    assert(std::bind(A_int_1(), _1)(i) == 3);
+    assert(std::bind(A_int_1(), i)() == 3);
+    }
+    // member function pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem1, _1)(a) == 3);
+    assert(std::bind(&A_int_1::mem1, a)() == 3);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::mem1, _1)(ap) == 3);
+    assert(std::bind(&A_int_1::mem1, ap)() == 3);
+    }
+    // const member function pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+    assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::mem2, _1)(ap) == 4);
+    assert(std::bind(&A_int_1::mem2, ap)() == 4);
+    }
+    // member data pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    assert(std::bind(&A_int_1::data_, a)() == 5);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    std::bind(&A_int_1::data_, _1)(a) = 6;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+    assert(std::bind(&A_int_1::data_, _1)(ap) == 6);
+    std::bind(&A_int_1::data_, _1)(ap) = 7;
+    assert(std::bind(&A_int_1::data_, _1)(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    int i = 2;
+    int j = 3;
+    std::bind(f_void_2, _1, _2)(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, i, _1)(j);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, i, j)();
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    int j = 3;
+    std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j);
+    assert(count == save_count+3);
+    save_count = count;
+    std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2());
+    assert(count == save_count+3);
+    save_count = count;
+    }
+}
+
+struct TFENode
+{
+    bool foo(unsigned long long) const
+    {
+        return true;
+    }
+};
+
+void
+test3()
+{
+    using namespace std;
+    using namespace std::placeholders;
+    const auto f = bind(&TFENode::foo, _1, 0UL);
+    const TFENode n = TFENode{};
+    bool b = f(n);
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,266 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    std::bind(f_void_1, _1)(2);
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    {
+    std::bind(f_void_1, 2)();
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::bind(fp, _1)(3);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    {
+    void (*fp)(int) = f_void_1;
+    std::bind(fp, 3)();
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::bind(a0, _1)(4);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    {
+    A_void_1 a0;
+    std::bind(a0, 4)();
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::bind(fp, _1)(A_void_1());
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, _1)(&a);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::bind(fp, A_void_1())();
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, &a)();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::bind(fp, _1)(A_void_1());
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, _1)(&a);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::bind(fp, A_void_1())();
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, &a)();
+    assert(count == save_count+2);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    using namespace std::placeholders;
+    // function
+    {
+    assert(std::bind(f_int_1, _1)(2) == 3);
+    assert(std::bind(f_int_1, 2)() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    assert(std::bind(fp, _1)(3) == 4);
+    assert(std::bind(fp, 3)() == 4);
+    }
+    // functor
+    {
+    assert(std::bind(A_int_1(), _1)(4) == 3);
+    assert(std::bind(A_int_1(), 4)() == 3);
+    }
+    // member function pointer
+    {
+    assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3);
+    assert(std::bind(&A_int_1::mem1, A_int_1())() == 3);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem1, _1)(&a) == 3);
+    assert(std::bind(&A_int_1::mem1, &a)() == 3);
+    }
+    // const member function pointer
+    {
+    assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+    assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem2, _1)(&a) == 4);
+    assert(std::bind(&A_int_1::mem2, &a)() == 4);
+    }
+    // member data pointer
+    {
+    assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5);
+    assert(std::bind(&A_int_1::data_, A_int_1())() == 5);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    std::bind(&A_int_1::data_, _1)(a) = 6;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+    assert(std::bind(&A_int_1::data_, _1)(&a) == 6);
+    std::bind(&A_int_1::data_, _1)(&a) = 7;
+    assert(std::bind(&A_int_1::data_, _1)(&a) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    std::bind(f_void_2, _1, _2)(2, 3);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, 2, _1)(3);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, 2, 3)();
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3);
+    assert(count == save_count+3);
+    save_count = count;
+    std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2());
+    assert(count == save_count+3);
+    save_count = count;
+    }
+}
+
+int f_nested(int i)
+{
+    return i+1;
+}
+
+int g_nested(int i)
+{
+    return i*10;
+}
+
+void test_nested()
+{
+    using namespace std::placeholders;
+    assert(std::bind(f_nested, std::bind(g_nested, _1))(3) == 31);
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    test_nested();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+template <class F>
+void
+test(F f)
+{
+    int save_count = count;
+    f();
+    assert(count == save_count + 1);
+}
+
+template <class F>
+void
+test_const(const F& f)
+{
+    int save_count = count;
+    f();
+    assert(count == save_count + 2);
+}
+
+void f() {++count;}
+
+struct A_int_0
+{
+    void operator()() {++count;}
+    void operator()() const {count += 2;}
+};
+
+int main()
+{
+    test(std::bind(f));
+    test(std::bind(&f));
+    test(std::bind(A_int_0()));
+    test_const(std::bind(A_int_0()));
+
+    test(std::bind<void>(f));
+    test(std::bind<void>(&f));
+    test(std::bind<void>(A_int_0()));
+    test_const(std::bind<void>(A_int_0()));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16343
+
+#include <cmath>
+#include <functional>
+#include <cassert>
+
+struct power
+{
+  template <typename T>
+  T
+  operator()(T a, T b)
+  {
+    return std::pow(a, b);
+  }
+};
+
+struct plus_one
+{
+  template <typename T>
+  T
+  operator()(T a)
+  {
+    return a + 1;
+  }
+};
+
+int
+main()
+{
+    using std::placeholders::_1;
+
+    auto g = std::bind(power(), 2, _1);
+    assert(g(5) == 32);
+    assert(std::bind(plus_one(), g)(5) == 33);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<class T> struct is_bind_expression
+
+#include <functional>
+
+template <bool Expected, class T>
+void
+test(const T&)
+{
+    static_assert(std::is_bind_expression<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+    test<true>(std::bind(C()));
+    test<true>(std::bind(C(), std::placeholders::_2));
+    test<true>(std::bind<int>(C()));
+    test<false>(1);
+    test<false>(std::placeholders::_2);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// struct is_placeholder
+
+#include <functional>
+
+template <int Expected, class T>
+void
+test(const T&)
+{
+    static_assert(std::is_placeholder<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+    test<1>(std::placeholders::_1);
+    test<2>(std::placeholders::_2);
+    test<3>(std::placeholders::_3);
+    test<4>(std::placeholders::_4);
+    test<5>(std::placeholders::_5);
+    test<6>(std::placeholders::_6);
+    test<7>(std::placeholders::_7);
+    test<8>(std::placeholders::_8);
+    test<9>(std::placeholders::_9);
+    test<10>(std::placeholders::_10);
+    test<0>(4);
+    test<0>(5.5);
+    test<0>('a');
+    test<0>(C());
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// placeholders
+
+#include <functional>
+
+template <class T>
+void
+test(const T& t)
+{
+    T t2;
+    T t3 = t;
+}
+
+int main()
+{
+    test(std::placeholders::_1);
+    test(std::placeholders::_2);
+    test(std::placeholders::_3);
+    test(std::placeholders::_4);
+    test(std::placeholders::_5);
+    test(std::placeholders::_6);
+    test(std::placeholders::_7);
+    test(std::placeholders::_8);
+    test(std::placeholders::_9);
+    test(std::placeholders::_10);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_and<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0xEA95);
+    assert(f(0xEA95, 0x58D3) == 0x4891);
+    assert(f(0x58D3, 0xEA95) == 0x4891);
+    assert(f(0x58D3, 0) == 0);
+    assert(f(0xFFFF, 0x58D3) == 0x58D3);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_and<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0x4891);
+    assert(f2(0xEA95L, 0x58D3) == 0x4891);
+    assert(f2(0xEA95, 0x58D3L) == 0x4891);
+
+    assert(f2(0x58D3, 0xEA95) == 0x4891);
+    assert(f2(0x58D3L, 0xEA95) == 0x4891);
+    assert(f2(0x58D3, 0xEA95L) == 0x4891);
+
+    assert(f2(0x58D3, 0) == 0);
+    assert(f2(0x58D3L, 0) == 0);
+    assert(f2(0x58D3, 0L) == 0);
+
+    assert(f2(0xFFFF, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
+
+    constexpr int foo = std::bit_and<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0x4891, "" );
+
+    constexpr int bar = std::bit_and<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0x4891, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_not<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    assert((f(0xEA95) & 0xFFFF ) == 0x156A);
+    assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
+    assert((f(0)      & 0xFFFF ) == 0xFFFF);
+    assert((f(0xFFFF) & 0xFFFF ) == 0);
+
+    typedef std::bit_not<> F2;
+    const F2 f2 = F2();
+    assert((f2(0xEA95)  & 0xFFFF ) == 0x156A);
+    assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
+    assert((f2(0x58D3)  & 0xFFFF ) == 0xA72C);
+    assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
+    assert((f2(0)       & 0xFFFF ) == 0xFFFF);
+    assert((f2(0L)      & 0xFFFF ) == 0xFFFF);
+    assert((f2(0xFFFF)  & 0xFFFF ) == 0);
+    assert((f2(0xFFFFL)  & 0xFFFF ) == 0);
+
+    constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
+    static_assert ( foo == 0x156A, "" );
+
+    constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
+    static_assert ( bar == 0x156A, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_or<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0xEA95);
+    assert(f(0xEA95, 0x58D3) == 0xFAD7);
+    assert(f(0x58D3, 0xEA95) == 0xFAD7);
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0xFFFF, 0x58D3) == 0xFFFF);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_or<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0) == 0x58D3);
+    assert(f2(0x58D3L, 0) == 0x58D3);
+    assert(f2(0x58D3, 0L) == 0x58D3);
+
+    assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
+
+    constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0xFAD7, "" );
+
+    constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0xFAD7, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_xor
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_xor<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0);
+    assert(f(0xEA95, 0x58D3) == 0xB246);
+    assert(f(0x58D3, 0xEA95) == 0xB246);
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0xFFFF, 0x58D3) == 0xA72C);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_xor<> F2;
+    const F2 f2 = F2();
+    assert(f(0xEA95, 0xEA95) == 0);
+    assert(f(0xEA95L, 0xEA95) == 0);
+    assert(f(0xEA95, 0xEA95L) == 0);
+
+    assert(f(0xEA95, 0x58D3) == 0xB246);
+    assert(f(0xEA95L, 0x58D3) == 0xB246);
+    assert(f(0xEA95, 0x58D3L) == 0xB246);
+
+    assert(f(0x58D3, 0xEA95) == 0xB246);
+    assert(f(0x58D3L, 0xEA95) == 0xB246);
+    assert(f(0x58D3, 0xEA95L) == 0xB246);
+
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0x58D3L, 0) == 0x58D3);
+    assert(f(0x58D3, 0L) == 0x58D3);
+
+    assert(f(0xFFFF, 0x58D3) == 0xA72C);
+    assert(f(0xFFFFL, 0x58D3) == 0xA72C);
+    assert(f(0xFFFF, 0x58D3L) == 0xA72C);
+
+    constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0xB246, "" );
+
+    constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0xB246, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::bit_and<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_and<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_and<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_and<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_or<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_or<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_or<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_or<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_xor<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_xor<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_xor<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_xor<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_not<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_not<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_not<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_not<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::equal_to<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::equal_to<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(!f2(36, 6));
+    assert(f2(36, 36.0));
+    assert(f2(36.0, 36L));
+
+    constexpr bool foo = std::equal_to<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::equal_to<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::greater<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(f(36, 6));
+    assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+
+    constexpr bool foo = std::greater<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::greater<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::greater_equal<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(f(36, 6));
+    assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater_equal<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+
+    constexpr bool foo = std::greater_equal<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::greater_equal<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::less<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(!f(36, 6));
+    assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+
+    constexpr bool foo = std::less<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::less<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::less_equal<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 6));
+    assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less_equal<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+
+    constexpr bool foo = std::less_equal<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::less_equal<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not_equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::not_equal_to<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::not_equal_to<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert( f2(36, 6));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(36.0, 36));
+    assert(!f2(36, 36.0));
+
+    constexpr bool foo = std::not_equal_to<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::not_equal_to<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::less<int>>::value, "" );
+    static_assert ( !is_transparent<std::less<std::string>>::value, "" );
+    static_assert (  is_transparent<std::less<void>>::value, "" );
+    static_assert (  is_transparent<std::less<>>::value, "" );
+
+    static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
+    static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
+    static_assert (  is_transparent<std::less_equal<void>>::value, "" );
+    static_assert (  is_transparent<std::less_equal<>>::value, "" );
+
+    static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
+    static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
+    static_assert (  is_transparent<std::equal_to<void>>::value, "" );
+    static_assert (  is_transparent<std::equal_to<>>::value, "" );
+
+    static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
+    static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
+    static_assert (  is_transparent<std::not_equal_to<void>>::value, "" );
+    static_assert (  is_transparent<std::not_equal_to<>>::value, "" );
+
+    static_assert ( !is_transparent<std::greater<int>>::value, "" );
+    static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
+    static_assert (  is_transparent<std::greater<void>>::value, "" );
+    static_assert (  is_transparent<std::greater<>>::value, "" );
+
+    static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
+    static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
+    static_assert (  is_transparent<std::greater_equal<void>>::value, "" );
+    static_assert (  is_transparent<std::greater_equal<>>::value, "" );
+
+#endif
+
+    return 0;
+    }

Added: libcxx/trunk/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+    {
+    A a;
+    f(a) = 5;
+    assert(a.data_ == 5);
+    A* ap = &a;
+    f(ap) = 6;
+    assert(a.data_ == 6);
+    const A* cap = ap;
+    assert(f(cap) == f(ap));
+    f(cap) = 7;
+    }
+}
+
+int main()
+{
+    test(std::mem_fn(&A::data_));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+    {
+    A a;
+    f(a) = 5;
+    assert(a.data_ == 5);
+    A* ap = &a;
+    f(ap) = 6;
+    assert(a.data_ == 6);
+    const A* cap = ap;
+    assert(f(cap) == f(ap));
+    const F& cf = f;
+    assert(cf(ap) == f(ap));
+    }
+}
+
+int main()
+{
+    test(std::mem_fn(&A::data_));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() {return 'a';}
+    char test1(int) {return 'b';}
+    char test2(int, double) {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() const {return 'a';}
+    char test1(int) const {return 'b';}
+    char test2(int, double) const {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) const volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() const volatile {return 'a';}
+    char test1(int) const volatile {return 'b';}
+    char test2(int, double) const volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const volatile A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const volatile A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const volatile A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() volatile {return 'a';}
+    char test1(int) volatile {return 'b';}
+    char test2(int, double) volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    volatile A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    volatile A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    volatile A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/binary_function.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/binary_function.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/binary_function.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    typedef std::binary_function<int, short, bool> bf;
+    static_assert((std::is_same<bf::first_argument_type, int>::value), "");
+    static_assert((std::is_same<bf::second_argument_type, short>::value), "");
+    static_assert((std::is_same<bf::result_type, bool>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/invoke.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/invoke.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/invoke.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/invoke.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// [func.require]
+
+// INVOKE
+#if __cplusplus < 201103L
+int main () {}      // no __invoke in C++03
+#else
+
+#include <type_traits>
+
+template <typename T, int N>
+struct Array
+{
+    typedef T type[N];
+};
+
+struct Type
+{
+    Array<char, 1>::type& f1();
+    Array<char, 2>::type& f2() const;
+    
+    Array<char, 1>::type& g1()        &;
+    Array<char, 2>::type& g2() const  &;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Array<char, 3>::type& g3()       &&;
+    Array<char, 4>::type& g4() const &&;
+#endif
+};
+
+int main()
+{
+    static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type        >())) == 1, "");
+    static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const  >())) == 2, "");
+    
+    static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type       &>())) == 1, "");
+    static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type      &&>())) == 3, "");
+    static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
+#endif
+}
+#endif

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/unary_function.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/unary_function.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/unary_function.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    typedef std::unary_function<int, bool> uf;
+    static_assert((std::is_same<uf::argument_type, int>::value), "");
+    static_assert((std::is_same<uf::result_type, bool>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// class bad_function_call
+//     : public exception
+// {
+// public:
+//   // 20.7.16.1.1, constructor:
+//   bad_function_call();
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// bad_function_call();
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    std::bad_function_call ex;
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,137 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible  R, MoveConstructible ... ArgTypes>
+//   void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    explicit A(int j)
+    {
+        ++count;
+        data_[0] = j;
+    }
+
+    A(const A& a)
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = a.data_[i];
+    }
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = A(2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 1);
+    assert(f2.target<A>()->id() == 2);
+    swap(f1, f2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 2);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = g;
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    swap(f1, f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = A(1);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    swap(f1, f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = h;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(*f2.target<int(*)(int)>() == h);
+    swap(f1, f2);
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == h);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit operator bool() const
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    assert(!f);
+    f = g;
+    assert(f);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = (int (*)(int))0;
+    assert(!f);
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f = &A::foo;
+    assert(f);
+    assert(new_called == 0);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F>
+//   requires CopyConstructible<F> && Callable<F, ArgTypes..>
+//         && Convertible<Callable<F, ArgTypes...>::result_type
+//   operator=(F f);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = (int (*)(int))0;
+    assert(!f);
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f;
+    f = &A::foo;
+    assert(f);
+    assert(new_called == 0);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F> function(F);
+
+// Allow incomplete argument types in the __is_callable check
+
+#include <functional>
+
+struct X{
+    typedef std::function<void(X&)> callback_type;
+    virtual ~X() {}
+private:
+    callback_type _cb;
+};
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int>());
+    assert(!f);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> function(allocator_arg_t, const A&, F);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+class Foo {
+public:
+  void bar(int k) { }
+};
+
+int main()
+{
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<A>(), A());
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(), g);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(),
+                              (int (*)(int))0);
+    assert(!f);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f(std::allocator_arg,
+                                        test_allocator<int(A::*)(int)const>(),
+                                        &A::foo);
+    assert(f);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+    {
+    Foo f;
+    std::function<void(int)> fun = std::bind(&Foo::bar, &f, std::placeholders::_1);
+    fun(10);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, const function&);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), f);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<int(*)(int)>(), f);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    assert(new_called == 0);
+    non_default_test_allocator<std::function<int(int)>> al(1);
+    std::function<int(int)> f2(std::allocator_arg, al, g);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<int>(), f);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int>(), nullptr);
+    assert(!f);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, function&&);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), std::move(f));
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,133 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(const function& f);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(!f);
+    std::function<long(int)> g = f;
+    assert(new_called == 0);
+    assert(g.target<long(*)(int)>() == 0);
+    assert(g.target<A>() == 0);
+    assert(!g);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2 = std::move(f);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(const function& f);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2;
+    f2 = std::move(f);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit function();
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<int(int)> f;
+    assert(!f);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R()>
+
+// template<class F> function(F);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<void()> f(static_cast<void(*)()>(0));
+    assert(!f);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<int(int)> f(nullptr);
+    assert(!f);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(nullptr_t);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    f = nullptr;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    f = nullptr;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// member data pointer:  cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    A_int_1 a;
+    std::function<int& (const A_int_1*)> r2(fp);
+    const A_int_1* ap = &a;
+    assert(r2(ap) == 6);
+    r2(ap) = 7;
+    assert(r2(ap) == 7);
+    }
+}
+
+int main()
+{
+    test_int_1();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void (int)> r1(f_void_1);
+    int i = 2;
+    r1(i);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::function<void (int)> r1(fp);
+    int i = 3;
+    r1(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::function<void (int)> r1(a0);
+    int i = 4;
+    r1(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::function<void (A_void_1)> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::function<void (A_void_1*)> r2 = fp;
+    r2(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::function<void (A_void_1)> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    std::function<void (A_void_1*)> r2(fp);
+    A_void_1* ap = &a;
+    r2(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // function
+    {
+    std::function<int (int)> r1(f_int_1);
+    int i = 2;
+    assert(r1(i) == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    std::function<int (int)> r1(fp);
+    int i = 3;
+    assert(r1(i) == 4);
+    }
+    // functor
+    {
+    A_int_1 a0;
+    std::function<int (int)> r1(a0);
+    int i = 4;
+    assert(r1(i) == 3);
+    }
+    // member function pointer
+    {
+    int (A_int_1::*fp)() = &A_int_1::mem1;
+    std::function<int (A_int_1)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 3);
+    std::function<int (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 3);
+    }
+    // const member function pointer
+    {
+    int (A_int_1::*fp)() const = &A_int_1::mem2;
+    std::function<int (A_int_1)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 4);
+    std::function<int (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 4);
+    }
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::function<int& (A_int_1&)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    std::function<int& (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 6);
+    r2(ap) = 7;
+    assert(r2(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void (int, int)> r1(f_void_2);
+    int i = 2;
+    int j = 3;
+    r1(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int, int) = f_void_2;
+    std::function<void (int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    r1(i, j);
+    assert(count == save_count+7);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_2 a0;
+    std::function<void (int, int)> r1(a0);
+    int i = 4;
+    int j = 5;
+    r1(i, j);
+    assert(count == save_count+9);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_2::*fp)(int) = &A_void_2::mem1;
+    std::function<void (A_void_2, int)> r1(fp);
+    A_void_2 a;
+    int i = 3;
+    r1(a, i);
+    assert(count == save_count+3);
+    save_count = count;
+    std::function<void (A_void_2*, int)> r2(fp);
+    A_void_2* ap = &a;
+    r2(ap, i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+    std::function<void (A_void_2, int)> r1(fp);
+    A_void_2 a;
+    int i = 4;
+    r1(a, i);
+    assert(count == save_count+4);
+    save_count = count;
+    std::function<void (A_void_2*, int)> r2(fp);
+    A_void_2* ap = &a;
+    r2(ap, i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+    return i+j;
+}
+
+struct A_int_2
+{
+    int operator()(int i, int j)
+    {
+        return i+j;
+    }
+
+    int mem1(int i) {return i+1;}
+    int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+    // function
+    {
+    std::function<int (int, int)> r1(f_int_2);
+    int i = 2;
+    int j = 3;
+    assert(r1(i, j) == i+j);
+    }
+    // function pointer
+    {
+    int (*fp)(int, int) = f_int_2;
+    std::function<int (int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    assert(r1(i, j) == i+j);
+    }
+    // functor
+    {
+    A_int_2 a0;
+    std::function<int (int, int)> r1(a0);
+    int i = 4;
+    int j = 5;
+    assert(r1(i, j) == i+j);
+    }
+    // member function pointer
+    {
+    int(A_int_2::*fp)(int) = &A_int_2::mem1;
+    std::function<int (A_int_2, int)> r1(fp);
+    A_int_2 a;
+    int i = 3;
+    assert(r1(a, i) == i+1);
+    std::function<int (A_int_2*, int)> r2(fp);
+    A_int_2* ap = &a;
+    assert(r2(ap, i) == i+1);
+    }
+    // const member function pointer
+    {
+    int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+    std::function<int (A_int_2, int)> r1(fp);
+    A_int_2 a;
+    int i = 4;
+    assert(r1(a, i) == i+2);
+    std::function<int (A_int_2*, int)> r2(fp);
+    A_int_2* ap = &a;
+    assert(r2(ap, i) == i+2);
+    }
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    testint_2();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+    return 3;
+}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+    // function
+    {
+    std::function<int ()> r1(f_int_0);
+    assert(r1() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)() = f_int_0;
+    std::function<int ()> r1(fp);
+    assert(r1() == 3);
+    }
+    // functor
+    {
+    A_int_0 a0;
+    std::function<int ()> r1(a0);
+    assert(r1() == 4);
+    }
+}
+
+int main()
+{
+    test_int_0();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+    ++count;
+}
+
+struct A_void_0
+{
+    void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void ()> r1(f_void_0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)() = f_void_0;
+    std::function<void ()> r1(fp);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_0 a0;
+    std::function<void ()> r1(a0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+int main()
+{
+    test_void_0();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> void assign(F&&, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    f.assign(A(), test_allocator<A>());
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// void swap(function& other);
+
+// UNSUPPORTED: asan, msan
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    explicit A(int j)
+    {
+        ++count;
+        data_[0] = j;
+    }
+
+    A(const A& a)
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = a.data_[i];
+    }
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = A(2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 1);
+    assert(f2.target<A>()->id() == 2);
+    f1.swap(f2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 2);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = g;
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    f1.swap(f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = A(1);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    f1.swap(f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = h;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(*f2.target<int(*)(int)>() == h);
+    f1.swap(f2);
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == h);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_%3D%3D.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible  R, MoveConstructible ... ArgTypes>
+//   bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    assert(f == nullptr);
+    assert(nullptr == f);
+    f = g;
+    assert(f != nullptr);
+    assert(nullptr != f);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<typename T>
+//   requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+//   T*
+//   target();
+// template<typename T>
+//   requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+//   const T*
+//   target() const;
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(A::count == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    const std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    const std::function<int(int)> f = g;
+    assert(A::count == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// const std::type_info& target_type() const;
+
+#include <functional>
+#include <typeinfo>
+#include <cassert>
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f = A();
+    assert(f.target_type() == typeid(A));
+    }
+    {
+    std::function<int(int)> f;
+    assert(f.target_type() == typeid(void));
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, CopyConstructible... ArgTypes>
+// class function<R(ArgTypes...)>
+//   : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
+//                                       // ArgTypes contains T1
+//   : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
+//                                       // ArgTypes contains T1 and T2
+// {
+// public:
+//     typedef R result_type;
+//     ...
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((!std::is_base_of<std::unary_function <int, int>,
+                                           std::function<int()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, int>,
+                                           std::function<int()> >::value), "");
+    static_assert(( std::is_same<          std::function<int()>::result_type,
+                                                         int>::value), "");
+
+    static_assert(( std::is_base_of<std::unary_function <int, double>,
+                                           std::function<double(int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, double>,
+                                           std::function<double(int)> >::value), "");
+    static_assert(( std::is_same<          std::function<double(int)>::result_type,
+                                                         double>::value), "");
+
+    static_assert((!std::is_base_of<std::unary_function <int, double>,
+                                           std::function<double(int, char)> >::value), "");
+    static_assert(( std::is_base_of<std::binary_function<int, char, double>,
+                                           std::function<double(int, char)> >::value), "");
+    static_assert(( std::is_same<          std::function<double(int, char)>::result_type,
+                                                         double>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_and<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 0));
+    assert(!f(0, 36));
+    assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_and<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36, 0));
+    assert(!f2(0, 36));
+    assert( f2(36, 36L));
+    assert(!f2(36, 0L));
+    assert(!f2(0, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36L, 0));
+    assert(!f2(0L, 36));
+
+    constexpr bool foo = std::logical_and<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::logical_and<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_not<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    assert(!f(36));
+    assert(f(0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_not<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36));
+    assert( f2(0));
+    assert(!f2(36L));
+    assert( f2(0L));
+
+    constexpr bool foo = std::logical_not<int> () (36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::logical_not<> () (36);
+    static_assert ( !bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_or<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(f(36, 0));
+    assert(f(0, 36));
+    assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_or<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert( f2(36, 0));
+    assert( f2(0, 36));
+    assert( f2(36, 0L));
+    assert( f2(0, 36L));
+    assert(!f2(0, 0));
+    assert(!f2(0, 0L));
+    assert(!f2(0L, 0));
+
+    constexpr bool foo = std::logical_or<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::logical_or<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::logical_and<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_and<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_and<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_and<>>::value, "" );
+
+    static_assert ( !is_transparent<std::logical_or<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_or<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_or<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_or<>>::value, "" );
+
+    static_assert ( !is_transparent<std::logical_not<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_not<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_not<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_not<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }

Added: libcxx/trunk/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/negators/binary_negate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/negators/binary_negate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/negators/binary_negate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::binary_negate<std::logical_and<int> > F;
+    const F f = F(std::logical_and<int>());
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert( f(36, 0));
+    assert( f(0, 36));
+    assert( f(0, 0));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/negators/not1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/negators/not1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/negators/not1.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/negators/not1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not1
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_not<int> F;
+    assert(std::not1(F())(36));
+    assert(!std::not1(F())(0));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/negators/not2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/negators/not2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/negators/not2.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/negators/not2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not2
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_and<int> F;
+    assert(!std::not2(F())(36, 36));
+    assert( std::not2(F())(36, 0));
+    assert( std::not2(F())(0, 36));
+    assert( std::not2(F())(0, 0));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::unary_negate<std::logical_not<int> > F;
+    const F f = F(std::logical_not<int>());
+    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    assert(f(36));
+    assert(!f(0));
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/binary.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/binary.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/binary.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/binary.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from binary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+    typedef int argument_type;
+    typedef int result_type;
+};
+
+int main()
+{
+    static_assert((!std::is_base_of<std::binary_function<int, char, int>,
+                                    std::reference_wrapper<functor1> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor2> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor3> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor4> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, int>,
+                                    std::reference_wrapper<C> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float ()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                   std::reference_wrapper<float (int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float (int, int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float(*)()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                   std::reference_wrapper<float(*)(int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
+                                   std::reference_wrapper<float(C::*)()> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<C*, int, float>,
+                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
+                                   std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// operator T& () const;
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    T& r2 = r;
+    assert(&r2 == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper& operator=(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    T t2 = t;
+    std::reference_wrapper<T> r2(t2);
+    r2 = r;
+    assert(&r2.get() == &t);
+}
+
+void f() {}
+void g() {}
+
+void
+test_function()
+{
+    std::reference_wrapper<void ()> r(f);
+    std::reference_wrapper<void ()> r2(g);
+    r2 = r;
+    assert(&r2.get() == &f);
+}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test_function();
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    std::reference_wrapper<T> r2 = r;
+    assert(&r2.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T&&) = delete;
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::reference_wrapper<const int> r(3);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T& t);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    assert(&r.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    std::reference_wrapper<const int> r = std::cref(i);
+    assert(&r.get() == &i);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    const int i = 0;
+    std::reference_wrapper<const int> r1 = std::cref(i);
+    std::reference_wrapper<const int> r2 = std::cref(r1);
+    assert(&r2.get() == &i);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+// Don't allow binding to a temp
+
+#include <functional>
+
+struct A {};
+
+const A source() {return A();}
+
+int main()
+{
+    std::reference_wrapper<const A> r = std::ref(source());
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    std::reference_wrapper<int> r = std::ref(i);
+    assert(&r.get() == &i);
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t);
+
+#include <functional>
+#include <cassert>
+
+#include "counting_predicates.hpp"
+
+bool is5 ( int i ) { return i == 5; }
+
+template <typename T>
+bool call_pred ( T pred ) { return pred(5); }
+
+int main()
+{
+    {
+    int i = 0;
+    std::reference_wrapper<int> r1 = std::ref(i);
+    std::reference_wrapper<int> r2 = std::ref(r1);
+    assert(&r2.get() == &i);
+    }
+    {
+    unary_counting_predicate<bool(*)(int), int> cp(is5);
+    assert(!cp(6));
+    assert(cp.count() == 1);
+    assert(call_pred(cp));
+    assert(cp.count() == 1);
+    assert(call_pred(std::ref(cp)));
+    assert(cp.count() == 2);
+    }
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// member data pointer:  cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::reference_wrapper<int A_int_1::*> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    const A_int_1* ap = &a;
+    assert(r1(ap) == 6);
+    r1(ap) = 7;
+    assert(r1(ap) == 7);
+    }
+}
+
+int main()
+{
+    test_int_1();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,329 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void (int)> r1(f_void_1);
+    int i = 2;
+    r1(i);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::reference_wrapper<void (*)(int)> r1(fp);
+    int i = 3;
+    r1(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::reference_wrapper<A_void_1> r1(a0);
+    int i = 4;
+    r1(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::reference_wrapper<void (A_void_1::*)()> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    r1(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::reference_wrapper<void (A_void_1::*)() const> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    r1(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // function
+    {
+    std::reference_wrapper<int (int)> r1(f_int_1);
+    int i = 2;
+    assert(r1(i) == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    std::reference_wrapper<int (*)(int)> r1(fp);
+    int i = 3;
+    assert(r1(i) == 4);
+    }
+    // functor
+    {
+    A_int_1 a0;
+    std::reference_wrapper<A_int_1> r1(a0);
+    int i = 4;
+    assert(r1(i) == 3);
+    }
+    // member function pointer
+    {
+    int (A_int_1::*fp)() = &A_int_1::mem1;
+    std::reference_wrapper<int (A_int_1::*)()> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 3);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 3);
+    }
+    // const member function pointer
+    {
+    int (A_int_1::*fp)() const = &A_int_1::mem2;
+    std::reference_wrapper<int (A_int_1::*)() const> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 4);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 4);
+    }
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::reference_wrapper<int A_int_1::*> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 6);
+    r1(ap) = 7;
+    assert(r1(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void (int, int)> r1(f_void_2);
+    int i = 2;
+    int j = 3;
+    r1(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int, int) = f_void_2;
+    std::reference_wrapper<void (*)(int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    r1(i, j);
+    assert(count == save_count+7);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_2 a0;
+    std::reference_wrapper<A_void_2> r1(a0);
+    int i = 4;
+    int j = 5;
+    r1(i, j);
+    assert(count == save_count+9);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_2::*fp)(int) = &A_void_2::mem1;
+    std::reference_wrapper<void (A_void_2::*)(int)> r1(fp);
+    A_void_2 a;
+    int i = 3;
+    r1(a, i);
+    assert(count == save_count+3);
+    save_count = count;
+    A_void_2* ap = &a;
+    r1(ap, i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+    std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp);
+    A_void_2 a;
+    int i = 4;
+    r1(a, i);
+    assert(count == save_count+4);
+    save_count = count;
+    A_void_2* ap = &a;
+    r1(ap, i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+    return i+j;
+}
+
+struct A_int_2
+{
+    int operator()(int i, int j)
+    {
+        return i+j;
+    }
+
+    int mem1(int i) {return i+1;}
+    int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+    // function
+    {
+    std::reference_wrapper<int (int, int)> r1(f_int_2);
+    int i = 2;
+    int j = 3;
+    assert(r1(i, j) == i+j);
+    }
+    // function pointer
+    {
+    int (*fp)(int, int) = f_int_2;
+    std::reference_wrapper<int (*)(int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    assert(r1(i, j) == i+j);
+    }
+    // functor
+    {
+    A_int_2 a0;
+    std::reference_wrapper<A_int_2> r1(a0);
+    int i = 4;
+    int j = 5;
+    assert(r1(i, j) == i+j);
+    }
+    // member function pointer
+    {
+    int(A_int_2::*fp)(int) = &A_int_2::mem1;
+    std::reference_wrapper<int (A_int_2::*)(int)> r1(fp);
+    A_int_2 a;
+    int i = 3;
+    assert(r1(a, i) == i+1);
+    A_int_2* ap = &a;
+    assert(r1(ap, i) == i+1);
+    }
+    // const member function pointer
+    {
+    int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+    std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp);
+    A_int_2 a;
+    int i = 4;
+    assert(r1(a, i) == i+2);
+    A_int_2* ap = &a;
+    assert(r1(ap, i) == i+2);
+    }
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    testint_2();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+    return 3;
+}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+    // function
+    {
+    std::reference_wrapper<int ()> r1(f_int_0);
+    assert(r1() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)() = f_int_0;
+    std::reference_wrapper<int (*)()> r1(fp);
+    assert(r1() == 3);
+    }
+    // functor
+    {
+    A_int_0 a0;
+    std::reference_wrapper<A_int_0> r1(a0);
+    assert(r1() == 4);
+    }
+}
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+};
+
+int main()
+{
+    test_int_0();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+    ++count;
+}
+
+struct A_void_0
+{
+    void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void ()> r1(f_void_0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)() = f_void_0;
+    std::reference_wrapper<void (*)()> r1(fp);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_0 a0;
+    std::reference_wrapper<A_void_0> r1(a0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+int main()
+{
+    test_void_0();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for member typedef type
+
+#include <functional>
+#include <type_traits>
+
+class C {};
+
+int main()
+{
+    static_assert((std::is_same<std::reference_wrapper<C>::type,
+                                                       C>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void ()>::type,
+                                                       void ()>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type,
+                                                       int* (double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void(*)()>::type,
+                                                       void(*)()>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type,
+                                                       int*(*)(double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type,
+                                                       int*(C::*)(double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
+                                                       int (C::*)(double*) const volatile>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// Test that reference wrapper meets the requirements of TriviallyCopyable,
+// CopyConstructible and CopyAssignable.
+
+#include <functional>
+#include <type_traits>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+};
+#endif
+
+
+template <class T>
+void test()
+{
+    typedef std::reference_wrapper<T> Wrap;
+    static_assert(std::is_copy_constructible<Wrap>::value, "");
+    static_assert(std::is_copy_assignable<Wrap>::value, "");
+    // Extension up for standardization: See N4151.
+    static_assert(std::is_trivially_copyable<Wrap>::value, "");
+}
+
+int main()
+{
+    test<int>();
+    test<double>();
+    test<std::string>(); 
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly>(); 
+#endif
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/unary.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/unary.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/unary.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/unary.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from unary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+    typedef int argument_type;
+    typedef int result_type;
+};
+
+int main()
+{
+    static_assert((std::is_base_of<std::unary_function<int, char>,
+                                   std::reference_wrapper<functor1> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<char, int>,
+                                    std::reference_wrapper<functor2> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, int>,
+                                   std::reference_wrapper<functor3> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, int>,
+                                   std::reference_wrapper<functor4> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, int>,
+                                    std::reference_wrapper<C> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float(*)()> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, float>,
+                                   std::reference_wrapper<float (int)> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float (int, int)> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, float>,
+                                   std::reference_wrapper<float(*)(int)> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<C*, float>,
+                                   std::reference_wrapper<float(C::*)()> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
+                                   std::reference_wrapper<float(C::*)() const volatile> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<C*, float>,
+                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// has weak result type
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<char, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<char, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+class C {};
+
+template <class T>
+struct has_result_type
+{
+private:
+    struct two {char _; char __;};
+    template <class U> static two test(...);
+    template <class U> static char test(typename U::result_type* = 0);
+public:
+    static const bool value = sizeof(test<T>(0)) == 1;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
+                                char>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<functor2>::result_type,
+                                double>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<functor3>::result_type,
+                                float>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void()>::result_type,
+                                void>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type,
+                                void>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type,
+                                int>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<C()>::result_type,
+                                C>::value), "");
+    static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
+    static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
+    static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
+}

Added: libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+//  Hashing a struct w/o a defined hash should fail.
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+
+struct X {};
+
+int main()
+{
+    X x;
+    size_t h = std::hash<X>{} ( x );
+}

Added: libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/enum.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// make sure that we can hash enumeration values
+// Not very portable
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+enum class Colors { red, orange, yellow, green, blue, indigo, violet };
+enum class Cardinals { zero, one, two, three, five=5 };
+enum class LongColors : short { red, orange, yellow, green, blue, indigo, violet };
+enum class ShortColors : long { red, orange, yellow, green, blue, indigo, violet };
+enum class EightBitColors : uint8_t { red, orange, yellow, green, blue, indigo, violet };
+
+enum Fruits { apple, pear, grape, mango, cantaloupe };
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    typedef typename std::underlying_type<T>::type under_type;
+    
+    std::hash<T> h1;
+    std::hash<under_type> h2;
+    for (int i = 0; i <= 5; ++i)
+    {
+        T t(static_cast<T> (i));
+        if (sizeof(T) <= sizeof(std::size_t))
+            assert(h1(t) == h2(static_cast<under_type>(i)));
+    }
+}
+
+int main()
+{
+    test<Cardinals>();
+
+    test<Colors>();
+    test<ShortColors>();
+    test<LongColors>();
+    test<EightBitColors>();
+
+    test<Fruits>();
+}
+#else
+int main () {}
+#endif

Added: libcxx/trunk/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/floating.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/floating.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/floating.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+#include <cmath>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    std::size_t t0 = h(0.);
+    std::size_t tn0 = h(-0.);
+    std::size_t tp1 = h(0.1);
+    std::size_t t1 = h(1);
+    std::size_t tn1 = h(-1);
+    std::size_t pinf = h(INFINITY);
+    std::size_t ninf = h(-INFINITY);
+    assert(t0 == tn0);
+    assert(t0 != tp1);
+    assert(t0 != t1);
+    assert(t0 != tn1);
+    assert(t0 != pinf);
+    assert(t0 != ninf);
+
+    assert(tp1 != t1);
+    assert(tp1 != tn1);
+    assert(tp1 != pinf);
+    assert(tp1 != ninf);
+
+    assert(t1 != tn1);
+    assert(t1 != pinf);
+    assert(t1 != ninf);
+
+    assert(tn1 != pinf);
+    assert(tn1 != ninf);
+
+    assert(pinf != ninf);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    for (int i = 0; i <= 5; ++i)
+    {
+        T t(i);
+        if (sizeof(T) <= sizeof(std::size_t))
+            assert(h(t) == t);
+    }
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<char16_t>();
+    test<char32_t>();
+    test<wchar_t>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    typedef typename std::remove_pointer<T>::type type;
+    type i;
+    type j;
+    assert(h(&i) != h(&j));
+}
+
+int main()
+{
+    test<int*>();
+}

Added: libcxx/trunk/test/std/utilities/function.objects/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/version.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+#include <functional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// class make_integer_sequence
+
+#include <tuple>
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <typename AtContainer, typename T, T... I>
+auto extract ( const AtContainer &t, const std::integer_sequence<T, I...> idx )
+-> decltype ( std::make_tuple ( std::get<I>(t)... ))
+{     return  std::make_tuple ( std::get<I>(t)... ); }
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Make a couple of sequences
+    using int3    = std::make_integer_sequence<int, 3>;     // generates int:    0,1,2
+    using size7   = std::make_integer_sequence<size_t, 7>;  // generates size_t: 0,1,2,3,4,5,6
+    using size4   = std::make_index_sequence<4>;            // generates size_t: 0,1,2,3
+    using size2   = std::index_sequence_for<int, size_t>;   // generates size_t: 0,1
+    using intmix  = std::integer_sequence<int, 9, 8, 7, 2>; // generates int:    9,8,7,2
+    using sizemix = std::index_sequence<1, 1, 2, 3, 5>;     // generates size_t: 1,1,2,3,5
+    
+//  Make sure they're what we expect
+    static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+    static_assert ( int3::size () == 3, "int3 size wrong" );
+    
+    static_assert ( std::is_same<size7::value_type, size_t>::value, "size7 type wrong" );
+    static_assert ( size7::size () == 7, "size7 size wrong" );
+    
+    static_assert ( std::is_same<size4::value_type, size_t>::value, "size4 type wrong" );
+    static_assert ( size4::size () == 4, "size4 size wrong" );
+    
+    static_assert ( std::is_same<size2::value_type, size_t>::value, "size2 type wrong" );
+    static_assert ( size2::size () == 2, "size2 size wrong" );
+    
+    static_assert ( std::is_same<intmix::value_type, int>::value, "intmix type wrong" );
+    static_assert ( intmix::size () == 4, "intmix size wrong" );
+
+    static_assert ( std::is_same<sizemix::value_type, size_t>::value, "sizemix type wrong" );
+    static_assert ( sizemix::size () == 5, "sizemix size wrong" );
+
+    auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
+    
+//  Use them
+    auto t3 = extract ( tup, int3() );
+    static_assert ( std::tuple_size<decltype(t3)>::value == int3::size (), "t3 size wrong");
+    assert ( t3 == std::make_tuple ( 10, 11, 12 ));
+
+    auto t7 = extract ( tup, size7 ());
+    static_assert ( std::tuple_size<decltype(t7)>::value == size7::size (), "t7 size wrong");
+    assert ( t7 == std::make_tuple ( 10, 11, 12, 13, 14, 15, 16 ));
+
+    auto t4 = extract ( tup, size4 ());
+    static_assert ( std::tuple_size<decltype(t4)>::value == size4::size (), "t4 size wrong");
+    assert ( t4 == std::make_tuple ( 10, 11, 12, 13 ));
+
+    auto t2 = extract ( tup, size2 ());
+    static_assert ( std::tuple_size<decltype(t2)>::value == size2::size (), "t2 size wrong");
+    assert ( t2 == std::make_tuple ( 10, 11 ));
+
+    auto tintmix = extract ( tup, intmix ());
+    static_assert ( std::tuple_size<decltype(tintmix)>::value == intmix::size (), "tintmix size wrong");
+    assert ( tintmix == std::make_tuple ( 19, 18, 17, 12 ));
+
+    auto tsizemix = extract ( tup, sizemix ());
+    static_assert ( std::tuple_size<decltype(tsizemix)>::value == sizemix::size (), "tsizemix size wrong");
+    assert ( tsizemix == std::make_tuple ( 11, 11, 12, 13, 15 ));
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+//     typedef T type;
+// 
+//     static constexpr size_t size() noexcept;
+// };
+
+// This test is a conforming extension.  The extension turns undefined behavior
+//  into a compile-time error.
+
+#include <utility>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Should fail to compile, since float is not an integral type
+    using floatmix = std::integer_sequence<float>;
+    floatmix::value_type I;
+
+#else
+
+X
+
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+//     typedef T type;
+// 
+//     static constexpr size_t size() noexcept;
+// };
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Make a few of sequences
+    using int3    = std::integer_sequence<int, 3, 2, 1>;
+    using size1   = std::integer_sequence<size_t, 7>;
+    using ushort2 = std::integer_sequence<unsigned short, 4, 6>;
+    using bool0   = std::integer_sequence<bool>;
+    
+//  Make sure they're what we expect
+    static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+    static_assert ( int3::size() == 3, "int3 size wrong" );
+    
+    static_assert ( std::is_same<size1::value_type, size_t>::value, "size1 type wrong" );
+    static_assert ( size1::size() == 1, "size1 size wrong" );
+    
+    static_assert ( std::is_same<ushort2::value_type, unsigned short>::value, "ushort2 type wrong" );
+    static_assert ( ushort2::size() == 2, "ushort2 size wrong" );
+    
+    static_assert ( std::is_same<bool0::value_type, bool>::value, "bool0 type wrong" );
+    static_assert ( bool0::size() == 0, "bool0 size wrong" );
+    
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+//   using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    std::make_integer_sequence<int, -3>::value_type i;
+
+#else
+
+X
+
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+//   using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    static_assert(std::is_same<std::make_integer_sequence<int, 0>, std::integer_sequence<int>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 1>, std::integer_sequence<int, 0>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 2>, std::integer_sequence<int, 0, 1>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 3>, std::integer_sequence<int, 0, 1, 2>>::value, "");
+
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 0>, std::integer_sequence<unsigned long long>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 1>, std::integer_sequence<unsigned long long, 0>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 2>, std::integer_sequence<unsigned long long, 0, 1>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 3>, std::integer_sequence<unsigned long long, 0, 1, 2>>::value, "");
+
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/intseq/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/intseq/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/intseq/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// struct allocator_arg_t { };
+// const allocator_arg_t allocator_arg = allocator_arg_t();
+
+#include <memory>
+
+void test(std::allocator_arg_t) {}
+
+int main()
+{
+    test(std::allocator_arg);
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static pointer allocate(allocator_type& a, size_type n);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 10);
+        return (value_type*)0xDEADBEEF;
+    }
+};
+
+int main()
+{
+    A<int> a;
+    assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF);
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 10);
+        return (value_type*)0xDEADBEEF;
+    }
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 12);
+        return (value_type*)0xEEADBEEF;
+    }
+    value_type* allocate(std::size_t n, const void* p)
+    {
+        assert(n == 11);
+        assert(p == 0);
+        return (value_type*)0xFEADBEEF;
+    }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    A<int> a;
+    assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF);
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    B<int> b;
+    assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF);
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class Ptr, class... Args>
+//         static void construct(allocator_type& a, Ptr p, Args&&... args);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+int b_construct = 0;
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class U, class ...Args>
+    void construct(U* p, Args&& ...args)
+    {
+        ++b_construct;
+        ::new ((void*)p) U(std::forward<Args>(args)...);
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+};
+
+struct A0
+{
+    static int count;
+    A0() {++count;}
+};
+
+int A0::count = 0;
+
+struct A1
+{
+    static int count;
+    A1(char c)
+    {
+        assert(c == 'c');
+        ++count;
+    }
+};
+
+int A1::count = 0;
+
+struct A2
+{
+    static int count;
+    A2(char c, int i)
+    {
+        assert(c == 'd');
+        assert(i == 5);
+        ++count;
+    }
+};
+
+int A2::count = 0;
+
+int main()
+{
+    {
+        A0::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        assert(A0::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+        assert(A0::count == 1);
+    }
+    {
+        A1::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A1)>::type a1;
+        assert(A1::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A1*)&a1, 'c');
+        assert(A1::count == 1);
+    }
+    {
+        A2::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A2)>::type a2;
+        assert(A2::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
+        assert(A2::count == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        A0::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        assert(A0::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+        assert(A0::count == 1);
+        assert(b_construct == 1);
+    }
+    {
+        A1::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A1)>::type a1;
+        assert(A1::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A1*)&a1, 'c');
+        assert(A1::count == 1);
+        assert(b_construct == 1);
+    }
+    {
+        A2::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A2)>::type a2;
+        assert(A2::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A2*)&a2, 'd', 5);
+        assert(A2::count == 1);
+        assert(b_construct == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static void deallocate(allocator_type& a, pointer p, size_type n);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int called = 0;
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    void deallocate(value_type* p, std::size_t n)
+    {
+        assert(p == (value_type*)0xDEADBEEF);
+        assert(n == 10);
+        ++called;
+    }
+};
+
+int main()
+{
+    A<int> a;
+    std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10);
+    assert(called == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class Ptr>
+//         static void destroy(allocator_type& a, Ptr p);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+int b_destroy = 0;
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    template <class U>
+    void destroy(U* p)
+    {
+        ++b_destroy;
+        p->~U();
+    }
+};
+
+struct A0
+{
+    static int count;
+    ~A0() {++count;}
+};
+
+int A0::count = 0;
+
+int main()
+{
+    {
+        A0::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+        assert(A0::count == 0);
+        std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
+        assert(A0::count == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        A0::count = 0;
+        b_destroy = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+        assert(A0::count == 0);
+        assert(b_destroy == 0);
+        std::allocator_traits<B<int> >::destroy(b, (A0*)&a0);
+        assert(A0::count == 1);
+        assert(b_destroy == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static size_type max_size(const allocator_type& a) noexcept;
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    size_t max_size() const
+    {
+        return 100;
+    }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        A<int> a;
+        assert(std::allocator_traits<A<int> >::max_size(a) ==
+               std::numeric_limits<std::size_t>::max());
+    }
+    {
+        const A<int> a = {};
+        assert(std::allocator_traits<A<int> >::max_size(a) ==
+               std::numeric_limits<std::size_t>::max());
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        B<int> b;
+        assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+    }
+    {
+        const B<int> b = {};
+        assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+    }
+#if __cplusplus >= 201103
+    {
+        std::allocator<int> a;
+        static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");
+    }
+#endif
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static allocator_type
+//         select_on_container_copy_construction(const allocator_type& a);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    int id;
+    explicit A(int i = 0) : id(i) {}
+
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    int id;
+    explicit B(int i = 0) : id(i) {}
+
+    B select_on_container_copy_construction() const
+    {
+        return B(100);
+    }
+};
+
+int main()
+{
+    {
+        A<int> a;
+        assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+    }
+    {
+        const A<int> a(0);
+        assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        B<int> b;
+        assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+    }
+    {
+        const B<int> b(0);
+        assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<T> pointer;
+    typedef CPtr<const T> const_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<const void> const_void_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::const_void_pointer, Ptr<const void> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::const_void_pointer, const void*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::const_void_pointer, CPtr<const void> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::difference_type
+//           | pointer_traits<pointer>::difference_type         difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef short difference_type;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    struct pointer {};
+    struct const_pointer {};
+    struct void_pointer {};
+    struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+    typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::difference_type, signed char>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::pointer | value_type* pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_copy_assignment
+//           | false_type                   propagate_on_container_copy_assignment;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_copy_assignment;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_move_assignment
+//           | false_type                   propagate_on_container_move_assignment;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_move_assignment;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_move_assignment, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_move_assignment, std::false_type>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_swap
+//           | false_type                   propagate_on_container_swap;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_swap, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_swap, std::false_type>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+    typedef T value_type;
+
+    template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, ReboundA<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, ReboundB<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, ReboundA<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, ReboundB<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::size_type | size_t    size_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef unsigned short size_type;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    struct pointer {};
+    struct const_pointer {};
+    struct void_pointer {};
+    struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+    typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::size_type,
+                   std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::size_type,
+                   unsigned char>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<void> void_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc allocator_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::allocator_type, A<char> >::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+    typedef T value_type;
+
+    template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/value_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/value_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/value_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef typename Alloc::value_type value_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::value_type, char>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class Alloc> struct uses_allocator;
+
+#include <memory>
+#include <vector>
+
+struct A
+{
+};
+
+struct B
+{
+    typedef int allocator_type;
+};
+
+int main()
+{
+    static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+    static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+    static_assert(( std::uses_allocator<B, double>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib> and <cstring> are already tested elsewhere
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+
+// template <class T1, class T2>
+//   bool
+//   operator==(const allocator<T1>&, const allocator<T2>&) throw();
+//
+// template <class T1, class T2>
+//   bool
+//   operator!=(const allocator<T1>&, const allocator<T2>&) throw();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::allocator<int> a1;
+    std::allocator<int> a2;
+    assert(a1 == a2);
+    assert(!(a1 != a2));
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer address(reference x) const;
+// const_pointer address(const_reference x) const;
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+void test_address()
+{
+    T* tp = new T();
+    const T* ctp = tp;
+    const std::allocator<T> a;
+    assert(a.address(*tp) == tp);
+    assert(a.address(*ctp) == tp);
+    delete tp;
+}
+
+struct A
+{
+    void operator&() const {}
+};
+
+int main()
+{
+    test_address<int>();
+    test_address<A>();
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
+
+// UNSUPPORTED: asan, msan
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    assert(s == 3 * sizeof(int));
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    int data;
+    A() {++A_constructed;}
+    A(const A&) {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::allocator<A> a;
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+    A* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+
+    A* ap2 = a.allocate(3, (const void*)5);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+    a.deallocate(ap2, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// template <class... Args> void construct(pointer p, Args&&... args);
+
+// UNSUPPORTED: asan, msan
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    assert(s == 3 * sizeof(int));
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    int data;
+    A() {++A_constructed;}
+
+    A(const A&) {++A_constructed;}
+
+    explicit A(int) {++A_constructed;}
+    A(int, int*) {++A_constructed;}
+
+    ~A() {--A_constructed;}
+};
+
+int move_only_constructed = 0;
+
+class move_only
+{
+    int data;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {++move_only_constructed;}
+    move_only& operator=(move_only&&) {return *this;}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {++move_only_constructed;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {++move_only_constructed;}
+    ~move_only() {--move_only_constructed;}
+};
+
+int main()
+{
+    {
+    std::allocator<A> a;
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+
+    A* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, A());
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, 5);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, 5, (int*)0);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+    }
+    {
+    std::allocator<move_only> a;
+    assert(new_called == 0);
+    assert(move_only_constructed == 0);
+
+    move_only* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.construct(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.construct(ap, move_only());
+    assert(new_called == 1);
+    assert(move_only_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(move_only_constructed == 0);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// size_type max_size() const throw();
+
+#include <memory>
+#include <limits>
+#include <cstddef>
+#include <cassert>
+
+int new_called = 0;
+
+int main()
+{
+    const std::allocator<int> a;
+    std::size_t M = a.max_size() * sizeof(int);
+    assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max());
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc                        allocator_type;
+//     typedef typename allocator_type::value_type
+//                                          value_type;
+// 
+//     typedef Alloc::pointer | value_type* pointer;
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//                                          const_pointer;
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+     typename std::allocator_traits<Alloc>::pointer        vp;
+     typename std::allocator_traits<Alloc>::const_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+     typename std::allocator_traits<Alloc>::void_pointer        vp;
+     typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+    test_pointer<std::allocator<char>> ();
+    test_pointer<std::allocator<int>> ();
+    test_pointer<std::allocator<Foo>> ();   
+
+    test_void_pointer<std::allocator<char>> ();
+    test_void_pointer<std::allocator<int>> ();
+    test_void_pointer<std::allocator<Foo>> ();  
+}
+#else
+int main() {}
+#endif

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// check nested types:
+
+// template <class T>
+// class allocator
+// {
+// public:
+//     typedef size_t                                size_type;
+//     typedef ptrdiff_t                             difference_type;
+//     typedef T*                                    pointer;
+//     typedef const T*                              const_pointer;
+//     typedef typename add_lvalue_reference<T>::type       reference;
+//     typedef typename add_lvalue_reference<const T>::type const_reference;
+//     typedef T                                     value_type;
+//
+//     template <class U> struct rebind {typedef allocator<U> other;};
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cstddef>
+
+int main()
+{
+    static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
+    static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<std::allocator<char>::value_type, char>::value), "");
+    static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
+    static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
+    static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
+                                std::allocator<int> >::value), "");
+    std::allocator<char> a;
+    std::allocator<char> a2 = a;
+    a2 = a;
+    std::allocator<int> a3 = a2;
+}

Added: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <>
+// class allocator<void>
+// {
+// public:
+//     typedef void*                                 pointer;
+//     typedef const void*                           const_pointer;
+//     typedef void                                  value_type;
+//
+//     template <class _Up> struct rebind {typedef allocator<_Up> other;};
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::allocator<void>::pointer, void*>::value), "");
+    static_assert((std::is_same<std::allocator<void>::const_pointer, const void*>::value), "");
+    static_assert((std::is_same<std::allocator<void>::value_type, void>::value), "");
+    static_assert((std::is_same<std::allocator<void>::rebind<int>::other,
+                                std::allocator<int> >::value), "");
+    std::allocator<void> a;
+    std::allocator<void> a2 = a;
+    a2 = a;
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     typedef ptrdiff_t difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/element_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/element_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/element_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/element_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     typedef T element_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef Ptr pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef short element_type;
+    typedef char difference_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), "");
+    static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     static pointer pointer_to(<details>);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+private:
+    struct nat {};
+public:
+    typedef T element_type;
+    element_type* t_;
+
+    A(element_type* t) : t_(t) {}
+
+    static A pointer_to(typename std::conditional<std::is_void<element_type>::value,
+                                           nat, element_type>::type& et)
+        {return A(&et);}
+};
+
+int main()
+{
+    {
+        int i = 0;
+        A<int> a = std::pointer_traits<A<int> >::pointer_to(i);
+        assert(a.t_ == &i);
+    }
+    {
+        (std::pointer_traits<A<void> >::element_type)0;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef <details> difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef short element_type;
+    typedef char difference_type;
+};
+
+struct B
+{
+    typedef short element_type;
+};
+
+template <class T>
+struct C {};
+
+template <class T>
+struct D
+{
+    typedef char difference_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef <details> element_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef char element_type;
+};
+
+template <class T>
+struct B
+{
+    typedef char element_type;
+};
+
+template <class T>
+struct C
+{
+};
+
+template <class T, class U>
+struct D
+{
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     template <class U> using rebind = <details>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+};
+
+template <class T> struct B1 {};
+
+template <class T>
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class U> using rebind = B1<U>;
+#else
+    template <class U> struct rebind {typedef B1<U> other;};
+#endif
+};
+
+template <class T, class U>
+struct C
+{
+};
+
+template <class T, class U> struct D1 {};
+
+template <class T, class U>
+struct D
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class V> using rebind = D1<V, U>;
+#else
+    template <class V> struct rebind {typedef D1<V, U> other;};
+#endif
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     static pointer pointer_to(<details>);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        int* a = std::pointer_traits<int*>::pointer_to(i);
+        assert(a == &i);
+    }
+    {
+        (std::pointer_traits<void*>::element_type)0;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.traits/rebind.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/pointer.traits/rebind.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/pointer.traits/rebind.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     template <class U> using rebind = U*;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
+#else
+    static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
+#endif
+}

Added: libcxx/trunk/test/std/utilities/memory/ptr.align/align.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/ptr.align/align.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/ptr.align/align.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/ptr.align/align.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// #include <memory>
+
+// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    const unsigned N = 20;
+    char buf[N];
+    void* r;
+    void* p = &buf[0];
+    std::size_t s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-3);
+
+    p = &buf[2];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-2);
+
+    p = &buf[3];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-1);
+
+    p = &buf[4];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(4, N, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-4, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-4);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-3, p, s);
+    assert(p == &buf[1]);
+    assert(r == nullptr);
+    assert(s == N-1);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(1, N+1, p, s);
+    assert(p == &buf[0]);
+    assert(r == nullptr);
+    assert(s == N);
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <ObjectType T> T* addressof(T& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    void operator&() const {}
+};
+
+struct nothing {
+    operator char&()
+    {
+        static char c;
+        return c;
+    }
+};
+
+int main()
+{
+    {
+    int i;
+    double d;
+    assert(std::addressof(i) == &i);
+    assert(std::addressof(d) == &d);
+    A* tp = new A;
+    const A* ctp = tp;
+    assert(std::addressof(*tp) == tp);
+    assert(std::addressof(*ctp) == tp);
+    delete tp;
+    }
+    {
+    union
+    {
+        nothing n;
+        int i;
+    };
+    assert(std::addressof(n) == (void*)std::addressof(i));
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class ForwardIterator>
+//   ForwardIterator
+//   uninitialized_copy(InputIterator first, InputIterator last,
+//                      ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    B b[N];
+    try
+    {
+        std::uninitialized_copy(b, b+N, bp);
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_copy(b, b+2, bp);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class Size, class ForwardIterator>
+//   ForwardIterator
+//   uninitialized_copy_n(InputIterator first, Size n,
+//                        ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    B b[N];
+    try
+    {
+        std::uninitialized_copy_n(b, 5, bp);
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_copy_n(b, 2, bp);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class Size, class T>
+//   ForwardIterator
+//   uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    try
+    {
+        std::uninitialized_fill_n(bp, 5, B());
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    B* r = std::uninitialized_fill_n(bp, 2, B());
+    assert(r == bp + 2);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class T>
+//   void
+//   uninitialized_fill(ForwardIterator first, ForwardIterator last,
+//                      const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    try
+    {
+        std::uninitialized_fill(bp, bp+N, B());
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_fill(bp, bp+2, B());
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    int data_;
+public:
+    explicit A(int i) : data_(i) {++A_constructed;}
+
+    A(const A& a) : data_(a.data_)  {++A_constructed;}
+    ~A() {--A_constructed; data_ = 0;}
+
+    bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+    typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+            Storage;
+    Storage buffer;
+    std::raw_storage_iterator<A*, A> it((A*)&buffer);
+    assert(A_constructed == 0);
+    for (int i = 0; i < 3; ++i)
+    {
+        *it++ = A(i+1);
+        A* ap = (A*)&buffer + i;
+        assert(*ap == i+1);
+        assert(A_constructed == i+1);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+//   pair<T*, ptrdiff_t>
+//   get_temporary_buffer(ptrdiff_t n);
+//
+// template <class T>
+//   void
+//   return_temporary_buffer(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(5);
+    assert(ip.first);
+    assert(ip.second == 5);
+    std::return_temporary_buffer(ip.first);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/deleter.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/deleter.h?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/deleter.h (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/deleter.h Fri Dec 19 19:40:03 2014
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(0) {}
+    explicit Deleter(int s) : state_(s) {}
+    ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class Deleter<T[]>
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(0) {}
+    explicit Deleter(int s) : state_(s) {}
+    ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(Deleter<T>& x, Deleter<T>& y)
+{
+    Deleter<T> t(std::move(x));
+    x = std::move(y);
+    y = std::move(t);
+}
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+public:
+
+    CDeleter() : state_(0) {}
+    explicit CDeleter(int s) : state_(s) {}
+    ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+    template <class U>
+        CDeleter(const CDeleter<U>& d)
+            : state_(d.state()) {}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class CDeleter<T[]>
+{
+    int state_;
+
+public:
+
+    CDeleter() : state_(0) {}
+    explicit CDeleter(int s) : state_(s) {}
+    ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(CDeleter<T>& x, CDeleter<T>& y)
+{
+    CDeleter<T> t(std::move(x));
+    x = std::move(y);
+    y = std::move(t);
+}
+
+#endif  // DELETER_H

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+//    The only way to create an unique_ptr<T[]> is to default construct them.
+
+class foo {
+public:
+    foo () : val_(3) {}
+    int get () const { return val_; }
+private:
+    int val_;
+    };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    auto p1 = std::make_unique<int[]>(5);
+    for ( int i = 0; i < 5; ++i )
+        assert ( p1[i] == 0 );
+    }
+    
+    {
+    auto p2 = std::make_unique<std::string[]>(5);
+    for ( int i = 0; i < 5; ++i )
+        assert ( p2[i].size () == 0 );
+    }
+    
+    {
+    auto p3 = std::make_unique<foo[]>(7);
+    for ( int i = 0; i < 7; ++i )
+        assert ( p3[i].get () == 3 );
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up1 = std::make_unique<std::string[]>("error"); // doesn't compile - no bound
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up2 = std::make_unique<int[]>(10, 20, 30, 40);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up3 = std::make_unique<int[5]>();    // this is deleted
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up4 = std::make_unique<int[5]>(11, 22, 33, 44, 55); // deleted 
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    std::unique_ptr<int> p1 = std::make_unique<int>(1);
+    assert ( *p1 == 1 );
+    p1 = std::make_unique<int> ();
+    assert ( *p1 == 0 );
+    }
+    
+    {
+    std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" );
+    assert ( *p2 == "Meow!" );
+    p2 = std::make_unique<std::string> ();
+    assert ( *p2 == "" );
+    p2 = std::make_unique<std::string> ( 6, 'z' );
+    assert ( *p2 == "zzzzzz" );
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    std::default_delete<B> d2;
+    std::default_delete<A> d1 = d2;
+    A* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d1(p);
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    std::default_delete<A> d;
+    A* p = new A;
+    assert(A::count == 1);
+    d(p);
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+    std::default_delete<A> d;
+    A* p = 0;
+    d(p);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::default_delete<const void> d;
+    const void* p = 0;
+    d(p);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> does not have a working converting constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct B
+    : public A
+{
+};
+
+int main()
+{
+    std::default_delete<B[]> d2;
+    std::default_delete<A[]> d1 = d2;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> has a working default constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    std::default_delete<A[]> d;
+    A* p = new A[3];
+    assert(A::count == 3);
+    d(p);
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]>'s operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+    std::default_delete<A[]> d;
+    A* p = 0;
+    d(p);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s1(new A[3]);
+    A* p = s1.get();
+    assert(A::count == 3);
+    std::unique_ptr<A[]> s2(new A[2]);
+    assert(A::count == 5);
+    s2 = std::move(s1);
+    assert(A::count == 3);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5));
+    A* p = s1.get();
+    assert(A::count == 4);
+    std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]);
+    assert(A::count == 9);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 4);
+    assert(s2.get_deleter().state() == 5);
+    assert(s1.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter<A[]> d1(5);
+    std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1);
+    A* p = s1.get();
+    assert(A::count == 6);
+    CDeleter<A[]> d2(6);
+    std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2);
+    assert(A::count == 9);
+    s2 = std::move(s1);
+    assert(A::count == 6);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(d1.state() == 5);
+    assert(d2.state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A[]> s(new A[3]);
+    std::unique_ptr<A[]> s2;
+    s2 = s;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const boost::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[]> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    const boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[]> s2(new A);
+    assert(A::count == 2);
+    s2 = boost::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = (boost::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = boost::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = 0;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(0) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {++state_;}
+};
+
+int main()
+{
+    Deleter d;
+    assert(d.state() == 0);
+    {
+    std::unique_ptr<int[], Deleter&> p(0, d);
+    assert(p.get() == 0);
+    assert(&p.get_deleter() == &d);
+    }
+    assert(d.state() == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s2(new A[3]);
+    assert(A::count == 3);
+    s2 = nullptr;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+    struct pointer {};
+};
+
+int main()
+{
+    {
+    typedef std::unique_ptr<int[]> P;
+    static_assert((std::is_same<P::pointer, int*>::value), "");
+    }
+    {
+    typedef std::unique_ptr<int[], Deleter> P;
+    static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require default Deleter ctor
+
+// USE_VERIFY
+
+#include <memory>
+
+class Deleter
+{
+    // expected-error at memory:* {{base class 'Deleter' has private default constructor}}
+    // expected-note at memory:* + {{in instantiation of member function}}
+    Deleter() {} // expected-note {{implicitly declared private here}}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) { return *this; }
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p;
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int[], Deleter> p;
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter&> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr<T[]> ctor
+
+// default unique_ptr<T[]> ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A[], D> a_;
+    B();
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+    {
+    B<> s;
+    assert(s.get() == 0);
+    }
+    check(0);
+    {
+    B<Deleter> s;
+    assert(s.get() == 0);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B() {}
+
+template <class D>
+B<D>::~B() {}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+    std::unique_ptr<int[], void (*)(void*)> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+    int state_;
+
+    NCDeleter(NCDeleter&);
+    NCDeleter& operator=(NCDeleter&);
+public:
+
+    NCDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5));
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    NCDeleter d;
+    std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
+    A* p = s.get();
+    std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+    int state_;
+
+    NCDeleter(NCDeleter&);
+    NCDeleter& operator=(NCDeleter&);
+public:
+
+    NCDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+std::unique_ptr<A[]>
+source1()
+{
+    return std::unique_ptr<A[]>(new A[3]);
+}
+
+void sink1(std::unique_ptr<A[]> p)
+{
+}
+
+std::unique_ptr<A[], Deleter<A[]> >
+source2()
+{
+    return std::unique_ptr<A[], Deleter<A[]> >(new A[3]);
+}
+
+void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
+{
+}
+
+std::unique_ptr<A[], NCDeleter&>
+source3()
+{
+    static NCDeleter d;
+    return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
+}
+
+void sink3(std::unique_ptr<A[], NCDeleter&> p)
+{
+}
+
+int main()
+{
+    sink1(source1());
+    sink2(source2());
+    sink3(source3());
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A[], Deleter> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A[], Deleter> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p(nullptr);
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int[], Deleter> p(nullptr);
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[]> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+#include <memory>
+
+// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter&> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A[]> >
+struct B
+{
+    std::unique_ptr<A[], D> a_;
+    explicit B(A*);
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+    {
+    A* p = get();
+    check(3);
+    B<> s(p);
+    assert(s.get() == p);
+    }
+    check(0);
+    {
+    A* p = get();
+    check(3);
+    B<Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A[3];}
+
+void Deleter::operator()(A* p) {delete [] p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+    std::unique_ptr<int[], void (*)(void*)> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr(pointer) ctor should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    B* p = new B[3];
+    std::unique_ptr<A[]> s(p);
+    }
+    {
+    B* p = new B[3];
+    std::unique_ptr<A[], Deleter> s(p);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], Deleter> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 6);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], const Deleter&> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], const Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter) should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    B* p = new B[3];
+    std::unique_ptr<A[], Deleter> s(p, Deleter());
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int[]> p(new int[3]);
+    int* i = p.get();
+    int* j = p.release();
+    assert(p.get() == 0);
+    assert(i == j);
+    delete [] j;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> p(new A[3]);
+    assert(A::count == 3);
+    A* i = p.get();
+    p.reset();
+    assert(A::count == 0);
+    assert(p.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[]> p(new A[4]);
+    assert(A::count == 4);
+    A* i = p.get();
+    p.reset(new A[5]);
+    assert(A::count == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> p(new A);
+    assert(A::count == 1);
+    assert(B::count == 0);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    std::unique_ptr<A[]> p(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    int state_;
+    static int count;
+    A() : state_(0) {++count;}
+    explicit A(int i) : state_(i) {++count;}
+    A(const A& a) : state_(a.state_) {++count;}
+    A& operator=(const A& a) {state_ = a.state_; return *this;}
+    ~A() {--count;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p1 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+    A* p2 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+    assert(s1.get() == p1);
+    assert(s1.get_deleter().state() == 1);
+    assert(s2.get() == p2);
+    assert(s2.get_deleter().state() == 2);
+    s1.swap(s2);
+    assert(s1.get() == p2);
+    assert(s1.get_deleter().state() == 2);
+    assert(s2.get() == p1);
+    assert(s2.get_deleter().state() == 1);
+    assert(A::count == 6);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int[]> p(new int(3));
+    assert(*p == 3);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p(new int [3]);
+    if (p)
+        ;
+    else
+        assert(false);
+    if (!p)
+        assert(false);
+    }
+    {
+    std::unique_ptr<int[]> p;
+    if (!p)
+        ;
+    else
+        assert(false);
+    if (p)
+        assert(false);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* p = new int[3];
+    std::unique_ptr<int[]> s(p);
+    assert(s.get() == p);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+    void operator()(void*) {}
+
+    int test() {return 5;}
+    int test() const {return 6;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[], Deleter> p;
+    assert(p.get_deleter().test() == 5);
+    }
+    {
+    const std::unique_ptr<int[], Deleter> p;
+    assert(p.get_deleter().test() == 6);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+    int state_;
+    static int next_;
+public:
+    A() : state_(++next_) {}
+    int get() const {return state_;}
+
+    friend bool operator==(const A& x, int y)
+        {return x.state_ == y;}
+
+    A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+    std::unique_ptr<A[]> p(new A[3]);
+    assert(p[0] == 1);
+    assert(p[1] == 2);
+    assert(p[2] == 3);
+    p[0] = 3;
+    p[1] = 2;
+    p[2] = 1;
+    assert(p[0] == 3);
+    assert(p[1] == 2);
+    assert(p[2] == 1);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    int i_;
+
+    A() : i_(7) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[]> p(new A);
+    assert(p->i_ == 7);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+    struct pointer {};
+};
+
+int main()
+{
+    {
+    typedef std::unique_ptr<int> P;
+    static_assert((std::is_same<P::pointer, int*>::value), "");
+    }
+    {
+    typedef std::unique_ptr<int, Deleter> P;
+    static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s1(new A);
+    A* p = s1.get();
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s1);
+    assert(A::count == 1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5));
+    A* p = s1.get();
+    std::unique_ptr<A, Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s1.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter<A> d1(5);
+    std::unique_ptr<A, CDeleter<A>&> s1(new A, d1);
+    A* p = s1.get();
+    CDeleter<A> d2(6);
+    std::unique_ptr<A, CDeleter<A>&> s2(new A, d2);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 1);
+    assert(d1.state() == 5);
+    assert(d2.state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    std::unique_ptr<B, Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    CDeleter<B> db(5);
+    std::unique_ptr<B, CDeleter<B>&> s(new B, db);
+    A* p = s.get();
+    CDeleter<A> da(6);
+    std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s.get_deleter().state() == 5);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    const std::unique_ptr<B, Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[], Deleter> s;
+    std::unique_ptr<A, Deleter> s2;
+    s2 = std::move(s);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = 0;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = nullptr;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up(std::move(ap));
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up;
+    up = std::move(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+//    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up;
+    up = ap;
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct Deleter
+{
+    template <class T>
+        void operator()(T*) {}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A, Deleter> up(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require default Deleter ctor
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int> p;
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int, Deleter> p;
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter&> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A, D> a_;
+    B() {}
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+    {
+    B<> s;
+    assert(s.get() == 0);
+    }
+    check(0);
+    {
+    B<Deleter> s;
+    assert(s.get() == 0);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::~B() {}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+int main()
+{
+    std::unique_ptr<int, void (*)(void*)> p;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A, Deleter<A> > s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter d;
+    std::unique_ptr<A, CDeleter&> s(new A, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+std::unique_ptr<A>
+source1()
+{
+    return std::unique_ptr<A>(new A);
+}
+
+void sink1(std::unique_ptr<A> p)
+{
+}
+
+std::unique_ptr<A, Deleter<A> >
+source2()
+{
+    return std::unique_ptr<A, Deleter<A> >(new A);
+}
+
+void sink2(std::unique_ptr<A, Deleter<A> > p)
+{
+}
+
+std::unique_ptr<A, CDeleter&>
+source3()
+{
+    static CDeleter d;
+    return std::unique_ptr<A, CDeleter&>(new A, d);
+}
+
+void sink3(std::unique_ptr<A, CDeleter&> p)
+{
+}
+
+int main()
+{
+    sink1(source1());
+    sink2(source2());
+    sink3(source3());
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// Can't construct from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    std::unique_ptr<A, Deleter<A> > s2 = s;
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    CDeleter<B> b(5);
+    std::unique_ptr<B, CDeleter<B>&> s(new B, b);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[], Deleter> s;
+    std::unique_ptr<A, Deleter> s2(std::move(s));
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int> p(nullptr);
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int, Deleter> p(nullptr);
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require default Deleter ctor
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should only require default Deleter ctor
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter&> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A, D> a_;
+    explicit B(A*);
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+    {
+    A* p = get();
+    check(1);
+    B<> s(p);
+    assert(s.get() == p);
+    }
+    check(0);
+    {
+    A* p = get();
+    check(1);
+    B<Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A;}
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-pointer Deleter
+
+int main()
+{
+    std::unique_ptr<int, void (*)(void*)> p(new int);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should work with derived pointers
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A, Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, Deleter> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 6);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, const Deleter&> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, const Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with derived pointers
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A, Deleter> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with function pointers
+// unique_ptr<void> should work
+
+bool my_free_called = false;
+
+void my_free(void*)
+{
+    my_free_called = true;
+}
+
+int main()
+{
+    {
+    int i = 0;
+    std::unique_ptr<void, void (*)(void*)> s(&i, my_free);
+    assert(s.get() == &i);
+    assert(s.get_deleter() == my_free);
+    assert(!my_free_called);
+    }
+    assert(my_free_called);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(0) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {++state_;}
+};
+
+int main()
+{
+    Deleter d;
+    assert(d.state() == 0);
+    {
+    std::unique_ptr<int, Deleter&> p(0, d);
+    assert(p.get() == 0);
+    assert(&p.get_deleter() == &d);
+    }
+    assert(d.state() == 0);
+}

Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
URL: