summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/memory
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-05-19 15:01:48 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-05-19 15:01:48 +0000
commita00932bddba1c4d1a9373f0367bd0cdf7896b0f7 (patch)
treefcda0a9459c8f6a51f1a0100ddc16d614aaaa107 /libcxx/test/std/utilities/memory
parent877f3cbe848f0b8dfbfea176925456cc9302bd89 (diff)
downloadbcm5719-llvm-a00932bddba1c4d1a9373f0367bd0cdf7896b0f7.tar.gz
bcm5719-llvm-a00932bddba1c4d1a9373f0367bd0cdf7896b0f7.zip
Implement LWG2433: uninitialized_copy()/etc. should tolerate overloaded operator&
llvm-svn: 237699
Diffstat (limited to 'libcxx/test/std/utilities/memory')
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp24
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp23
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp25
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp22
4 files changed, 94 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
index 7de7eccc65f..f431335db73 100644
--- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
+++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -28,8 +28,19 @@ struct B
int B::count_ = 0;
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
int main()
{
+ {
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
@@ -48,4 +59,17 @@ int main()
std::uninitialized_copy(b, b+2, bp);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy(arr, arr+N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
+
}
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
index 79afa4f8f18..3b2007b969c 100644
--- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
+++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -28,8 +28,19 @@ struct B
int B::count_ = 0;
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
int main()
{
+ {
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
@@ -48,4 +59,16 @@ int main()
std::uninitialized_copy_n(b, 2, bp);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy_n(arr, N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
}
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
index 8fc6b819484..d2b1dfa2886 100644
--- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
+++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -27,8 +27,19 @@ struct B
int B::count_ = 0;
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
int main()
{
+ {
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
@@ -47,4 +58,18 @@ int main()
assert(r == bp + 2);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ }
+ {
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill_n(bp, N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
+
+ }
}
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
index c34fdc7a14e..47cabdfa478 100644
--- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
+++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -28,8 +28,19 @@ struct B
int B::count_ = 0;
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
int main()
{
+ {
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
@@ -47,4 +58,15 @@ int main()
std::uninitialized_fill(bp, bp+2, B());
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill(bp, bp+N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
}
OpenPOWER on IntegriCloud