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 ForwardIterator, class Size, class T>
14 // uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
19 #include "test_macros.h"
24 static int population_;
26 explicit B() : data_(1) { ++population_; }
34 ~B() {data_ = 0; --population_; }
38 int B::population_ = 0;
42 Nasty() : i_ ( counter_++ ) {}
43 Nasty * operator &() const { return NULL; }
48 int Nasty::counter_ = 0;
54 char pool[sizeof(B)*N] = {0};
56 assert(B::population_ == 0);
57 #ifndef TEST_HAS_NO_EXCEPTIONS
60 std::uninitialized_fill_n(bp, 5, B());
65 assert(B::population_ == 0);
69 B* r = std::uninitialized_fill_n(bp, 2, B());
71 for (int i = 0; i < 2; ++i)
72 assert(bp[i].data_ == 1);
73 assert(B::population_ == 2);
78 char pool[N*sizeof(Nasty)] = {0};
79 Nasty* bp = (Nasty*)pool;
82 std::uninitialized_fill_n(bp, N, Nasty());
83 for (int i = 0; i < N; ++i)
84 assert(bp[i].i_ == 23);