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

std::uninitialized_move

Defined in header <memory>

template< class InputIt, class ForwardIt > ForwardIt uninitialized_move( InputIt first, InputIt last, ForwardIt d_first );

(1)

(since C++17)

template< class ExecutionPolicy, class InputIt, class ForwardIt > ForwardIt uninitialized_move( ExecutionPolicy&& policy, InputIt first, InputIt last, ForwardIt d_first );

(2)

(since C++17)

1%29移动范围内的元素[first, last)开始的未初始化内存区域。d_first好像

二次

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

二次

如果在初始化过程中引发异常,则[first, last)处于有效但未指定的状态。

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

参数

first, last

-

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实例进行增量、赋值、比较或间接转换,否则会引发异常。

返回值

Iterator到元素过去的最后一个元素移动。

复杂性

直线在之间的距离firstlast...

例外

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

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

可能的实施

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

*。

另见

uninitialized_copy

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

uninitialized_move_n (C++17)

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

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

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

扫码关注腾讯云开发者

领取腾讯云代金券