首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::uninitialized_move_n

Defined in header <memory>

template< class InputIt, class Size, class ForwardIt > std::pair<InputIt, ForwardIt> uninitialized_move_n( InputIt first, Size count, ForwardIt d_first );

(1)

(since C++17)

template< class ExecutionPolicy, class InputIt, class Size, class ForwardIt > std::pair<InputIt, ForwardIt> uninitialized_move_n( ExecutionPolicy&& policy, InputIt first, Size count, ForwardIt d_first );

(2)

(since C++17)

1%29次移动count元素的范围开始于first开始的未初始化内存区域。d_first好像

二次

代码语言:javascript
复制
for ( ; n > 0; ++d_first, (void) ++first, --n)
   ::new (static_cast<void*>(std::addressof(*d_first)))
      typename std::iterator_traits<ForwardIt>::value_type(std::move(*first));

二次

如果在初始化期间抛出异常,源范围中的某些对象将保持有效但未指定的状态。

2%29与%281%29相同,但根据policy此重载不参与过载解决,除非std::is_execution_policy_v<std::decay_t<ExecutionPolicy>>是真的

参数

first

-

the beginning of the range of the elements to move

d_first

-

the beginning of the destination range

policy

-

the execution policy to use. See execution policy for details.

类型要求

-输入必须符合输入器的要求。

---。

-不通过有效的Forward实例进行增量、赋值、比较或间接转换,否则会引发异常。

返回值

一对元素,其第一个元素是过去在源范围中移动的最后一个元素的迭代器,其第二个元素是在目标范围中移动的最后一个元素的迭代器。

复杂性

线性在count...

例外

带有名为ExecutionPolicy报告错误如下:

  • 如果执行作为算法一部分调用的函数,则引发异常ExecutionPolicy是其中之一标准政策,,,std::terminate叫做。对于任何其他人ExecutionPolicy,行为是由实现定义的。
  • 如果算法不能分配内存,std::bad_alloc被扔了。

可能的实施

模板<类输入,类大小,类向前>std::对<Inputit,Forwardit>未初始化[医]移动[医]n%28输入第一,大小计数,向前[医]第一%29{tydurif type Name std::iterator[医]性状<ForwardIt>*价值[医]类型值;正向电流=d[医]首先,尝试{表示%28;计数>0;++先,%28void%29++当前,-计数%29{::新的%28静态[医]铸造<空隙%2A>%28 std::地址%28%2A现值%29%29%29值%28%2A第一%29}捕获%28%29{%28;d[医]第一%21=电流;++d[医]第一%29{d[医]第一个->~值%28%29;}抛出;}返回{First,Current};}

*。

另见

uninitialized_move (C++17)

moves a range of objects to an uninitialized area of memory (function template)

uninitialized_copy_n (C++11)

copies a number of objects to an uninitialized area of memory (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券