diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-04-21 23:38:59 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-04-21 23:38:59 +0000 |
commit | f07dd8d0a925dd8cbde7bb6198c1ba92446110ea (patch) | |
tree | 581032748ea2b3640d2e7f033f2e651eb67416bd /libcxx/test/std/utilities/memory | |
parent | c89755e4cbad7a46d747f3b2d49c50a80855a801 (diff) | |
download | bcm5719-llvm-f07dd8d0a925dd8cbde7bb6198c1ba92446110ea.tar.gz bcm5719-llvm-f07dd8d0a925dd8cbde7bb6198c1ba92446110ea.zip |
Add is_swappable/is_nothrow_swappable traits
llvm-svn: 267079
Diffstat (limited to 'libcxx/test/std/utilities/memory')
-rw-r--r-- | libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp index 44b746fbcfd..c525137d484 100644 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp +++ b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp @@ -16,6 +16,7 @@ #include <memory> #include <cassert> +#include "test_macros.h" #include "../deleter.h" struct A @@ -34,6 +35,16 @@ struct A int A::count = 0; +template <class T> +struct NonSwappableDeleter { + explicit NonSwappableDeleter(int) {} + NonSwappableDeleter& operator=(NonSwappableDeleter const&) { return *this; } + void operator()(T*) const {} +private: + NonSwappableDeleter(NonSwappableDeleter const&); + +}; + int main() { { @@ -74,4 +85,18 @@ int main() assert(A::count == 6); } assert(A::count == 0); +#if TEST_STD_VER >= 11 + { + // test that unique_ptr's specialized swap is disabled when the deleter + // is non-swappable. Instead we should pick up the generic swap(T, T) + // and perform 3 move constructions. + typedef NonSwappableDeleter<int> D; + D d(42); + int x = 42; + int y = 43; + std::unique_ptr<int, D&> p(&x, d); + std::unique_ptr<int, D&> p2(&y, d); + std::swap(p, p2); + } +#endif } |