std::uninitialized_fill_n
来自cppreference.com
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 在头文件 <memory> 中定义
|
||
| template< class ForwardIt, class Size, class T > void uninitialized_fill_n( ForwardIt first, Size count, const T& value ) |
||
Copies the given value value to the first count elements in an uninitialized memory area beginning at first. The elements in the uninitialized area are constructed using copy constructor.
目录 |
[编辑] 参数
| first | - | the beginning of the range of the elements to initialize |
| count | - | number of elements to construct |
| value | - | 的值来构造的元素
原文: the value to construct the elements with |
| 类型要求 | ||
-ForwardIt 必须满足 ForwardIterator 的要求。
| ||
[编辑] 返回值
过去的最后一个元素的元素的迭代器,复制.
原文:
Iterator to the element past the last element copied.
[编辑] 复杂度
线性
count[编辑] 可能的实现
template< class ForwardIt, class Size, class T > void uninitialized_fill_n(ForwardIt first, Size count const T& value) { typedef typename std::iterator_traits<ForwardIt>::value_type Value; for (; count > 0; ++first, --count) { ::new (static_cast<void*>(&*first)) Value(value); } return first; } |
[编辑] 示例
| 本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
| 一个对象复制到一个未初始化的内存区域 原文: copies an object to an uninitialized area of memory (函数模板) | |