std::deque<T,Allocator>:: deque
|
deque
(
)
:
deque
(
Allocator
(
)
)
{
}
|
(1) |
(seit C++11)
(constexpr seit C++26) |
| (2) | ||
|
explicit
deque
(
const
Allocator
&
alloc
=
Allocator
(
)
)
;
|
(bis C++11) | |
|
explicit
deque
(
const
Allocator
&
alloc
)
;
|
(seit C++11)
(constexpr seit C++26) |
|
|
explicit
deque
(
size_type count,
const Allocator & alloc = Allocator ( ) ) ; |
(3) |
(seit C++11)
(constexpr seit C++26) |
| (4) | ||
|
explicit
deque
(
size_type count,
const
T
&
value
=
T
(
)
,
const Allocator & alloc = Allocator ( ) ) ; |
(bis C++11) | |
|
deque
(
size_type count,
const
T
&
value,
const Allocator & alloc = Allocator ( ) ) ; |
(seit C++11)
(constexpr seit C++26) |
|
|
template
<
class
InputIt
>
deque
(
InputIt first, InputIt last,
|
(5) | (constexpr seit C++26) |
|
template
<
container-compatible-range
<
T
>
R
>
deque
(
std::
from_range_t
, R
&&
rg,
|
(6) |
(seit C++23)
(constexpr seit C++26) |
|
deque
(
const
deque
&
other
)
;
|
(7) | (constexpr seit C++26) |
|
deque
(
deque
&&
other
)
;
|
(8) |
(seit C++11)
(constexpr seit C++26) |
| (9) | ||
|
deque
(
const
deque
&
other,
const
Allocator
&
alloc
)
;
|
(seit C++11)
(bis C++23) |
|
|
deque
(
const
deque
&
other,
const std:: type_identity_t < Allocator > & alloc ) ; |
(seit C++23)
(constexpr seit C++26) |
|
| (10) | ||
|
deque
(
deque
&&
other,
const
Allocator
&
alloc
)
;
|
(seit C++11)
(bis C++23) |
|
|
deque
(
deque
&&
other,
const
std::
type_identity_t
<
Allocator
>
&
alloc
)
;
|
(seit C++23)
(constexpr seit C++26) |
|
|
deque
(
std::
initializer_list
<
T
>
init,
const Allocator & alloc = Allocator ( ) ) ; |
(11) |
(seit C++11)
(constexpr seit C++26) |
Konstruiert einen neuen
deque
aus verschiedenen Datenquellen, optional unter Verwendung einer benutzerdefinierten Zuweisung
alloc
.
deque
mit einem standardkonstruierten Allokator.
deque
mit dem gegebenen Allokator
alloc
.
deque
mit
count
standardmäßig eingefügten Objekten von
T
. Es werden keine Kopien erstellt.
deque
mit
count
Kopien von Elementen mit dem Wert
value
.
|
Falls
|
(seit C++11) |
deque
mit den Inhalten des Bereichs
[
first
,
last
)
. Jeder Iterator in
[
first
,
last
)
wird genau einmal dereferenziert.
|
Falls
|
(bis C++11) |
|
Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn
Falls
|
(seit C++11) |
deque
mit den Inhalten des Bereichs
rg
. Jeder Iterator in
rg
wird genau einmal dereferenziert.
T
nicht
EmplaceConstructible
in
deque
von
*
ranges::
begin
(
rg
)
ist, ist das Verhalten undefiniert.
deque
mit den Inhalten von
other
.
|
Der Allokator wird bezogen, als ob durch Aufruf von
|
(since C++11) |
deque
mit den Inhalten von
other
. Der Allokator wird durch Move-Konstruktion von
other.
get_allocator
(
)
erhalten.
InhaltParameter
Komplexität
1,2)
Konstante.
3,4)
Linear in
count
.
5)
Linear in
std::
distance
(
first, last
)
.
6)
Linear in
ranges::
distance
(
rg
)
.
7)
Linear in
other.
size
(
)
.
8)
Konstante.
9)
Linear in
other.
size
(
)
.
10)
Linear in
other.
size
(
)
if
alloc
!
=
other.
get_allocator
(
)
, ansonsten konstant.
11)
Linear in
init.
size
(
)
.
AusnahmenAufrufe von Allocator :: allocate können eine Exception werfen. AnmerkungenNach Container-Move-Konstruktion (Überladung (8)), bleiben Referenzen, Zeiger und Iteratoren, die ursprünglich auf Elemente in
Beispiel
Diesen Code ausführen
#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 Initialisierungslisten-Syntax: 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 ist {"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); // Überladung (6) #else std::deque<std::string> words5(rg.begin(), rg.end()); // Überladung (5) #endif std::cout << "5: " << words5; } Ausgabe: 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}
FehlerberichteDie folgenden verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.
Siehe auch
|