المتغيرات
فضاءات التسمية
أفعال

std::{{{1}}}::{{{1}}}

من cppreference.com
(1)
explicit {{{1}}}( const Container& cont = Container() );
(until C++11)
explicit {{{1}}}( const Container& cont );
(since C++11)
explicit {{{1}}}( Container&& cont = Container() );
(2) (since C++11)
{{{1}}}( const {{{1}}}& other );
(3)
{{{1}}}( {{{1}}}&& other );
(4) (since C++11)
template< class Alloc >
explicit {{{1}}}( const Alloc& alloc );
(5) (since C++11)
template< class Alloc >
{{{1}}}( const Container& cont, const Alloc& alloc );
(6) (since C++11)
template< class Alloc >
{{{1}}}( Container&& cont, const Alloc& alloc );
(7) (since C++11)
template< class Alloc >
{{{1}}}( const {{{1}}}& other, const Alloc& alloc );
(8) (since C++11)
template< class Alloc >
{{{1}}}( {{{1}}}&& other, const Alloc& alloc );
(9) (since C++11)

Constructs new underlying container of the container adaptor from a variety of data sources.

1) Copy-constructs the underlying container ‎c‎ with the contents of ‎cont‎. This is also the default constructor (until C++11)
2) Move-constructs the underlying container ‎c‎ with std::move(cont). This is also the default constructor (since C++11)
3) Copy constructor. The adaptor is copy-constructed with the contents of other.c. (معلن عنه ضمنيا)
4) Move constructor. The adaptor is constructed with std::move(other.c). (معلن عنه ضمنيا)
5-9) The following constructors are only defined if std::uses_allocator<container_type, Alloc>::value == true, that is, if the underlying container is an allocator-aware container (true for all standard library containers).
5) Constructs the underlying container using ‎alloc‎ as allocator. Effectively calls c(alloc).
6) Constructs the underlying container with the contents of ‎cont‎ and using ‎alloc‎ as allocator. Effectively calls c(cont, alloc).
7) Constructs the underlying container with the contents of ‎cont‎ using move semantics while utilising ‎alloc‎ as allocator. Effectively calls c(std::move(cont), alloc).
8) Constructs the adaptor with the contents of ‎other.c‎ and using ‎alloc‎ as allocator. Effectively calls c(athor.c, alloc).
9) Constructs the adaptor with the contents of ‎other‎ using move semantics while utilising ‎alloc‎ as allocator. Effectively calls c(std::move(other.c), alloc).

محتويات

[تعديل] Parameters

alloc - allocator to use for all memory allocations of the underlying container
other - another container adaptor to be used as source to initialize the underlying container
cont - container to be used as source to initialize the underlying container
first, last - range of elements to initialize with

قالب:par hreq قالب:par req concept قالب:par req concept قالب:par req concept

[تعديل] Complexity

1, 3, 5, 6, 8: linear in ‎cont‎ or ‎other‎

2, 4, 7, 9: constant

[تعديل] Example

#include <{{{1}}}>
#include <deque>
#include <iostream>
 
int main()
{
    std::{{{1}}}<int> c1;
    c1.push(5);
    std::cout << c1.size() << '\n';
 
    std::{{{1}}}<int> c2(c1);
    std::cout << c2.size() << '\n';
 
    std::deque<int> deq {3, 1, 4, 1, 5};
    std::{{{1}}}<int> c3(deq);
    std::cout << c3.size() << '\n';
}

الخرج:

1
1
5

[تعديل] See also

قالب:dsc mem fun