1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class InputIterator, class ForwardIterator>
14 // uninitialized_copy(InputIterator first, InputIterator last,
15 // ForwardIterator result);
20 #include "test_macros.h"
25 static int population_;
27 explicit B() : data_(1) { ++population_; }
35 ~B() {data_ = 0; --population_; }
39 int B::population_ = 0;
43 Nasty() : i_ ( counter_++ ) {}
44 Nasty * operator &() const { return NULL; }
49 int Nasty::counter_ = 0;
55 char pool[sizeof(B)*N] = {0};
58 assert(B::population_ == N);
59 #ifndef TEST_HAS_NO_EXCEPTIONS
62 std::uninitialized_copy(b, b+N, bp);
67 assert(B::population_ == N);
71 std::uninitialized_copy(b, b+2, bp);
72 for (int i = 0; i < 2; ++i)
73 assert(bp[i].data_ == 1);
74 assert(B::population_ == N + 2);
79 char pool[sizeof(Nasty)*N] = {0};
80 Nasty * p = (Nasty *) pool;
82 std::uninitialized_copy(arr, arr+N, p);
83 for (int i = 0; i < N; ++i) {
84 assert(arr[i].i_ == i);
85 assert( p[i].i_ == i);