std::deque<T,Allocator>:: deque
|
deque
(
)
:
deque
(
Allocator
(
)
)
{
}
|
(1) |
(C++11以降)
(C++26以降 constexpr) |
| (2) | ||
|
explicit
deque
(
const
Allocator
&
alloc
=
Allocator
(
)
)
;
|
(C++11まで) | |
|
explicit
deque
(
const
Allocator
&
alloc
)
;
|
(C++11以降)
(constexprはC++26以降) |
|
|
explicit
deque
(
size_type count,
const Allocator & alloc = Allocator ( ) ) ; |
(3) |
(C++11以降)
(C++26以降 constexpr) |
| (4) | ||
|
explicit
deque
(
size_type count,
const
T
&
value
=
T
(
)
,
const Allocator & alloc = Allocator ( ) ) ; |
(C++11まで) | |
|
deque
(
size_type count,
const
T
&
value,
const Allocator & alloc = Allocator ( ) ) ; |
(C++11以降)
(C++26以降 constexpr) |
|
|
template
<
class
InputIt
>
deque
(
InputIt first, InputIt last,
|
(5) | (constexpr C++26以降) |
|
template
<
container-compatible-range
<
T
>
R
>
deque
(
std::
from_range_t
, R
&&
rg,
|
(6) |
(C++23以降)
(constexpr C++26以降) |
|
deque
(
const
deque
&
other
)
;
|
(7) | (constexpr C++26以降) |
|
deque
(
deque
&&
other
)
;
|
(8) |
(C++11以降)
(constexpr C++26以降) |
| (9) | ||
|
deque
(
const
deque
&
other,
const
Allocator
&
alloc
)
;
|
(C++11以降)
(C++23まで) |
|
|
deque
(
const
deque
&
other,
const std:: type_identity_t < Allocator > & alloc ) ; |
(C++23以降)
(C++26以降constexpr) |
|
| (10) | ||
|
deque
(
deque
&&
other,
const
Allocator
&
alloc
)
;
|
(C++11以降)
(C++23まで) |
|
|
deque
(
deque
&&
other,
const
std::
type_identity_t
<
Allocator
>
&
alloc
)
;
|
(C++23以降)
(C++26以降 constexpr) |
|
|
deque
(
std::
initializer_list
<
T
>
init,
const Allocator & alloc = Allocator ( ) ) ; |
(11) |
(C++11以降)
(C++26以降 constexpr) |
様々なデータソースから新しい
deque
を構築します。オプションでユーザー提供のアロケータ
alloc
を使用します。
deque
を構築します。
deque
を構築します。
deque
を
count
個のデフォルト構築された
T
オブジェクトで構築します。コピーは作成されません。
[
first
,
last
)
の内容を持つ
deque
を構築します。
[
first
,
last
)
内の各イテレータは正確に1回だけデリファレンスされます。
|
|
(C++11以前) |
|
このオーバーロードは、
|
(C++11以降) |
deque
を構築します。
rg
内の各イテレータは正確に一度だけデリファレンスされます。
deque
を
other
の内容で構築する。
|
アロケータは、以下の呼び出しによって取得されるかのように取得される:
|
(C++11以降) |
deque
を
other
の内容で構築します。アロケータは
other.
get_allocator
(
)
からのムーブ構築によって取得されます。
目次 |
パラメータ
| alloc | - | このコンテナのすべてのメモリ割り当てに使用するアロケータ |
| count | - | コンテナのサイズ |
| value | - | コンテナの要素を初期化するための値 |
| first, last | - | コピーする要素のソース 範囲 を定義するイテレータのペア |
| other | - | コンテナの要素を初期化するためのソースとして使用する別のコンテナ |
| init | - | コンテナの要素を初期化するための初期化子リスト |
| rg | - | コンテナ互換の範囲 |
計算量
例外
Allocator :: allocate の呼び出しは例外をスローする可能性があります。
注記
コンテナのムーブ構築後(オーバーロード ( 8 ) および ( 10 ) )、 other への参照、ポインタ、およびイテレータ(終端イテレータを除く)は有効なままですが、現在は * this 内の要素を参照します。現在の標準では、この保証は [container.reqmts]/67 の包括的な記述によって行われており、より直接的な保証は LWG issue 2321 を通じて検討中です。
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | レンジ対応 構築と挿入; オーバーロード ( 6 ) |
例
#include <deque> #include <iostream> #include <string> template<typename T> std::ostream& operator<<(std::ostream& s, const std::deque<T>& v) { s.put('{'); for (char comma[]{'\0', ' ', '\0'}; const auto& e : v) s << comma << e, comma[0] = ','; return s << "}\n"; } int main() { // C++11 初期化リスト構文: std::deque<std::string> words1{"the", "frogurt", "is", "also", "cursed"}; std::cout << "1: " << words1; // words2 == words1 std::deque<std::string> words2(words1.begin(), words1.end()); std::cout << "2: " << words2; // words3 == words1 std::deque<std::string> words3(words1); std::cout << "3: " << words3; // words4 は {"Mo", "Mo", "Mo", "Mo", "Mo"} std::deque<std::string> words4(5, "Mo"); std::cout << "4: " << words4; const auto rg = {"cat", "cow", "crow"}; #ifdef __cpp_lib_containers_ranges std::deque<std::string> words5(std::from_range, rg); // オーバーロード (6) #else std::deque<std::string> words5(rg.begin(), rg.end()); // オーバーロード (5) #endif std::cout << "5: " << words5; }
出力:
1: {the, frogurt, is, also, cursed}
2: {the, frogurt, is, also, cursed}
3: {the, frogurt, is, also, cursed}
4: {Mo, Mo, Mo, Mo, Mo}
5: {cat, cow, crow}
欠陥報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 144 | C++98 |
オーバーロード
(
5
)
の計算量要件は対応する
std::vector のオーバーロードと同じ |
線形計算量に変更 |
| LWG 237 | C++98 |
オーバーロード
( 5 ) の計算量要件は first - last に対して線形 |
std:: distance ( first, last ) に対して線形に変更 |
| LWG 438 | C++98 |
オーバーロード
(
5
)
は
InputIt
が整数型の場合のみ
オーバーロード ( 4 ) を呼び出す |
オーバーロード
(
4
)
を
InputIt
が LegacyInputIterator でない場合に呼び出す |
| LWG 2193 | C++11 | デフォルトコンストラクタはexplicit | non-explicitに変更 |
| LWG 2210 | C++11 | オーバーロード ( 3 ) にアロケータパラメータがなかった | パラメータを追加 |
| N3346 | C++11 |
オーバーロード
(
3
)
では、コンテナ内の
要素は値初期化されていた |
デフォルト挿入される |
関連項目
|
コンテナに値を割り当てる
(公開メンバ関数) |
|
|
コンテナに値を割り当てる
(公開メンバ関数) |