aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp')
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
new file mode 100644
index 000000000000..ed68052cd3bb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
@@ -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);
+}