std::multiset<Key,Compare,Allocator>:: multiset
| (1) | ||
|
multiset
(
)
;
|
(bis C++11) | |
|
multiset
(
)
:
multiset
(
Compare
(
)
)
{
}
|
(seit C++11)
(constexpr seit C++26) |
|
|
explicit
multiset
(
const
Compare
&
comp,
const Allocator & alloc = Allocator ( ) ) ; |
(2) | (constexpr seit C++26) |
|
explicit
multiset
(
const
Allocator
&
alloc
)
;
|
(3) |
(seit C++11)
(constexpr seit C++26) |
|
template
<
class
InputIt
>
multiset
(
InputIt first, InputIt last,
|
(4) | (constexpr seit C++26) |
|
template
<
class
InputIt
>
multiset
(
InputIt first, InputIt last,
|
(5) |
(seit C++14)
(constexpr seit C++26) |
|
multiset
(
const
multiset
&
other
)
;
|
(6) | (constexpr seit C++26) |
|
multiset
(
const
multiset
&
other,
const
Allocator
&
alloc
)
;
|
(7) |
(seit C++11)
(constexpr seit C++26) |
|
multiset
(
multiset
&&
other
)
;
|
(8) |
(seit C++11)
(constexpr seit C++26) |
|
multiset
(
multiset
&&
other,
const
Allocator
&
alloc
)
;
|
(9) |
(seit C++11)
(constexpr seit C++26) |
|
multiset
(
std::
initializer_list
<
value_type
>
init,
const
Compare
&
comp
=
Compare
(
)
,
|
(10) |
(seit C++11)
(constexpr seit C++26) |
|
multiset
(
std::
initializer_list
<
value_type
>
init,
const
Allocator
&
alloc
)
|
(11) |
(seit C++14)
(constexpr seit C++26) |
|
template
<
container-compatible-range
<
value_type
>
R
>
multiset
(
std::
from_range_t
, R
&&
rg,
|
(12) |
(seit C++23)
(constexpr seit C++26) |
|
template
<
container-compatible-range
<
value_type
>
R
>
multiset
(
std::
from_range_t
, R
&&
rg,
|
(13) |
(seit C++23)
(constexpr seit C++26) |
Konstruiert einen neuen Container aus verschiedenen Datenquellen und optional unter Verwendung eines benutzerdefinierten Allokators alloc oder Vergleichsfunktionsobjekts comp .
[
first
,
last
)
.
|
Falls
alloc
nicht bereitgestellt wird, wird der Allokator durch Aufruf von
std::
allocator_traits
<
allocator_type
>
::
|
(seit C++11) |
|
Während der
Klassentemplate-Argumentableitung
trägt nur das erste Argument zur Ableitung des
|
(seit C++23) |
|
Während der
Klassentemplate-Argumentableitung
trägt nur das erste Argument zur Ableitung des
|
(since C++23) |
InhaltParameter
Komplexität
1-3)
Konstant.
4,5)
N·log(N)
wobei
N
gleich
std::
distance
(
first, last
)
ist, im Allgemeinen linear in
N
falls
[
first
,
last
)
bereits nach
value_comp
(
)
sortiert ist.
6,7)
Linear in der Größe von
other
.
8,9)
Konstant. Wenn
alloc
angegeben ist und
alloc
!
=
other.
get_allocator
(
)
, dann linear.
10,11)
N·log(N)
wobei
N
die
init.
size
(
)
ist, im Allgemeinen linear in
N
falls
init
bereits nach
value_comp
(
)
sortiert ist.
12,13)
N·log(N)
wobei
N
ranges::
distance
(
rg
)
ist, im Allgemeinen linear in
N
falls
rg
bereits durch
value_comp
(
)
sortiert ist.
Ausnahmen
Aufrufe von
AnmerkungenNach Container-Verschiebekonstruktion (Überladung (8,9)), Verweise, Zeiger und Iteratoren, die ursprünglich auf Elemente in Obwohl erst mit C++23 formell gefordert, haben einige Implementierungen den Template-Parameter
Beispiel
Diesen Code ausführen
#include <iostream> #include <set> #include <string_view> template <typename T> void println(const std::string_view name, const std::multiset<T>& ms) { std::cout << name << ": "; for (const auto& element : ms) std::cout << element << ' '; std::cout << '\n'; } int main() { // (1) Standardkonstruktor std::multiset<int> a; a.insert(4); a.insert(3); a.insert(2); a.insert(1); println("a", a); // (4) Bereichskonstruktor std::multiset<int> b(a.begin(), a.find(3)); println("b", b); // (6) Kopierkonstruktor std::multiset<int> c(a); println("c", c); // (8) Move-Konstruktor std::multiset<int> d(std::move(a)); println("d", d); // (10) Initialisierungslisten-Konstruktor std::multiset<int> e{3, 2, 1, 2, 4, 7, 3}; println("e", e); // (12) Bereichskonstruktor const auto w = {"α", "β", "γ", "δ", "δ", "γ", "β", "α"}; #if __cpp_lib_containers_ranges std::multiset<std::string> f(std::from_range, w); // Überladung (12) #else std::multiset<std::string> f(w.begin(), w.end()); // Fallback auf (4) #endif println("f", f); } Ausgabe: a: 1 2 3 4 b: 1 2 c: 1 2 3 4 d: 1 2 3 4 e: 1 2 2 3 3 4 7 f: α α β β γ γ δ δ FehlerberichteDie folgenden verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.
Siehe auch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||