名前空間
変種
操作

「cpp/memory/uninitialized copy」の版間の差分

提供: cppreference.com
< cpp‎ | memory
(Translated from the English version using Google Translate)
 
 
(3人の利用者による、間の7版が非表示)
1行: 1行:
{{tr_note}}
 
 
{{cpp/title|uninitialized_copy}}
 
{{cpp/title|uninitialized_copy}}
 
{{cpp/memory/navbar}}
 
{{cpp/memory/navbar}}
{{ddcl | header=memory |  
+
{{
 +
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 );
 
}}
 
}}
 +
 +
 +
 +
  
{{tr|{{tt|[first, last)}}で始まる初期化されていないメモリ領域への範囲{{tt|d_first}}からコピーが要素。初期化されていない領域内の要素は、コピーコンストラクタを使用して構築されてい.|Copies elements from the range {{tt|[first, last)}} to an uninitialized memory area beginning at {{tt|d_first}}. The elements in the uninitialized area are constructed using copy constructor.}}
+
{{tt|[first, last)}} {{tt|d_first}}
 +
{{|
 +
first last)
 +
d_first
 +
 +
}}
  
===パラメータ===
+
{{param list begin}}
+
{{param list item | first, last |{{tr| コピーする要素の範囲| the range of the elements to copy}}}}
+
{{param list item | d_first |{{tr| 目的の範囲の始まり| the beginning of the destination range}}}}
+
{{param list hreq}}
+
{{param list req concept | InputIt | InputIterator}}
+
{{param list req concept | ForwardIt | ForwardIterator}}
+
{{param list end}}
+
  
===値を返します===
+
{{||}}
{{tr|コピーされた最後の要素過去の要素を指すイテレータ.|Iterator to the element past the last element copied.}}
+
  
===複雑===
+
======
{{tr|{{tt|first}}{{tt|last}}との間の距離の線形|Linear in the distance between {{tt|first}} and {{tt|last}}}}
+
{{
 +
{{| 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, ++d_first) {
+
    
        ::new (static_cast<void*>(&*d_first)) Value(*first);
+
 +
for (; first != last; ++first, ++) {
 +
::new (static_cast<void*>(*)) Value(*first)
 +
 +
 +
 +
 +
 +
 +
;
 
     }
 
     }
    return d_first;
 
 
}
 
}
 
}}
 
}}
40行: 67行:
 
{{example
 
{{example
 
  | code=
 
  | code=
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
  | output=
 
  | output=
 +
 
}}
 
}}
  
===も参照してください===
+
======
{{dcl list begin}}
+
{{begin}}
{{dcl list template | cpp/memory/dcl list uninitialized_copy_n}}
+
{{| cpp/memory/uninitialized_copy_n}}
{{dcl list end}}
+
 
 +
{{end}}
 +
 
 +
 +
 +
 +
 +
 +
 +
 +

2018年11月18日 (日) 00:59時点における最新版

 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
動的メモリ管理
スマートポインタ
(C++11)
(C++11)
(C++11)
(C++17未満)
(C++11)
アロケータ
メモリリソース
未初期化記憶域
ガベージコレクションサポート
その他
(C++20)
(C++11)
(C++11)
C のライブラリ
低水準のメモリ管理
 
ヘッダ <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 でなければ、オーバーロード解決に参加しません。

目次