git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@119699 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2010-11-18 16:13:03 +00:00
parent 278bf2d289
commit 2f6a627394
2 changed files with 7 additions and 4 deletions

View File

@ -155,7 +155,8 @@ template <class ForwardIterator, class T>
void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
template <class ForwardIterator, class Size, class T>
void uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
ForwardIterator
uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
template <class Y> struct auto_ptr_ref {};
@ -2512,7 +2513,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
}
template <class _ForwardIterator, class _Size, class _Tp>
void
_ForwardIterator
uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
{
__destruct_n __d(0);
@ -2521,6 +2522,7 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
for (; __n > 0; ++__f, --__n, __d.__incr((value_type*)0))
::new(&*__f) value_type(__x);
__h.release();
return __f;
}
class _LIBCPP_EXCEPTION_ABI bad_weak_ptr

View File

@ -10,7 +10,7 @@
// <memory>
// template <class ForwardIterator, class Size, class T>
// void
// ForwardIterator
// uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
#include <memory>
@ -43,7 +43,8 @@ int main()
assert(bp[i].data_ == 0);
}
B::count_ = 0;
std::uninitialized_fill_n(bp, 2, B());
B* r = std::uninitialized_fill_n(bp, 2, B());
assert(r == bp + 2);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
}