「cpp/memory/uninitialized copy」の版間の差分
提供: cppreference.com
TranslationBot (トーク | 投稿記録) (Translated from the English version using Google Translate) |
|||
(3人の利用者による、間の7版が非表示) | |||
1行: | 1行: | ||
− | |||
{{cpp/title|uninitialized_copy}} | {{cpp/title|uninitialized_copy}} | ||
{{cpp/memory/navbar}} | {{cpp/memory/navbar}} | ||
− | {{ | + | {{ |
+ | header memory | ||
+ | | | ||
template< class InputIt, class ForwardIt > | template< class InputIt, class ForwardIt > | ||
ForwardIt uninitialized_copy( InputIt first, InputIt last, ForwardIt d_first ); | ForwardIt uninitialized_copy( InputIt first, InputIt last, ForwardIt d_first ); | ||
}} | }} | ||
+ | |||
+ | |||
+ | |||
+ | |||
− | + | {{tt|[first, last)}} {{tt|d_first}} | |
+ | {{| | ||
+ | first last) | ||
+ | d_first | ||
+ | |||
+ | }} | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | {{||}} | |
− | {{ | + | |
− | === | + | ====== |
− | {{ | + | {{ |
+ | {{| first}} | ||
+ | {{| }} | ||
+ | |||
+ | |||
+ | | | ||
+ | {{| }} | ||
+ | {{tt|}} | ||
+ | }} | ||
− | === | + | === |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | === | ||
{{eq fun | 1= | {{eq fun | 1= | ||
template<class InputIt, class ForwardIt> | template<class InputIt, class ForwardIt> | ||
30行: | 49行: | ||
{ | { | ||
typedef typename std::iterator_traits<ForwardIt>::value_type Value; | typedef typename std::iterator_traits<ForwardIt>::value_type Value; | ||
− | for (; first != last; ++first, ++ | + | |
− | + | ||
+ | for (; first != last; ++first, ++) { | ||
+ | ::new (static_cast<void*>(*)) Value(*first) | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ; | ||
} | } | ||
− | |||
} | } | ||
}} | }} | ||
40行: | 67行: | ||
{{example | {{example | ||
| code= | | code= | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
| output= | | output= | ||
+ | |||
}} | }} | ||
− | === | + | ====== |
− | {{ | + | {{begin}} |
− | {{ | + | {{| cpp/memory/uninitialized_copy_n}} |
− | {{ | + | |
+ | {{end}} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ |
2018年11月18日 (日) 00:59時点における最新版
ヘッダ <memory> で定義
|
||
template< class InputIt, class ForwardIt > ForwardIt uninitialized_copy( InputIt first, InputIt last, ForwardIt d_first ); |
(1) | |
template< class ExecutionPolicy, class InputIt, class ForwardIt > ForwardIt uninitialized_copy( ExecutionPolicy&& policy, InputIt first, InputIt last, ForwardIt d_first ); |
(2) | (C++17以上) |
1) 以下のように行われたかのように、範囲
[first, last)
の要素を d_first
から始まる未初期化メモリ領域にコピーします。
for (; first != last; ++d_first, (void) ++first) ::new (static_cast<void*>(std::addressof(*d_first))) typename std::iterator_traits<ForwardIt>::value_type(*first);
初期化中に例外が投げられた場合、すでに構築されたオブジェクトは未規定の順序で破棄されます。
2) (1) と同じですが、
policy
に従って実行されます。 このオーバーロードは、 std::is_execution_policy_v<std::decay_t<ExecutionPolicy>> が true でなければ、オーバーロード解決に参加しません。目次 |