Пространства имён
Варианты
Действия

std::stack::stack

Материал из cppreference.com

 
 
 
зЬй :: стека
Член функций
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stack::stack
stack::~stack
stack::operator=
Элемент доступа
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stack::top
Потенциала
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stack::empty
stack::size
Модификаторы
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stack::push
stack::emplace
stack::pop
stack::swap
 
explicit stack( const Container& cont = Container() );
explicit stack( const Container& cont );
(1) (до C++11)
(начиная с C++11)
explicit stack( Container&& cont = Container() );
(2) (начиная с C++11)
stack( const stack& other );
(3)
stack( stack&& other );
(4) (начиная с C++11)
template< class Alloc >
explicit stack( const Alloc& alloc );
(5) (начиная с C++11)
template< class Alloc >
stack( const Container& cont, const Alloc& alloc );
(6) (начиная с C++11)
template< class Alloc >
stack( Container&& cont, const Alloc& alloc );
(7) (начиная с C++11)
template< class Alloc >
stack( const stack& other, const Alloc& alloc );
(8) (начиная с C++11)
template< class Alloc >
stack( stack&& other, const Alloc& alloc );
(9) (начиная с C++11)
Создает нового базового контейнера в контейнер адаптер из различных источников данных.
Original:
Constructs new underlying container of the container adaptor from a variety of data sources.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Копирование строит основные c контейнера с содержимым cont. Это также (до C++11) конструктор по умолчанию
Original:
Copy-constructs the underlying container c with the contents of cont. This is also the default constructor (до C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Move-строит базового контейнера c с std::move(cont). Это также (начиная с C++11) конструктор по умолчанию
Original:
Move-constructs the underlying container c with std::move(cont). This is also the default constructor (начиная с C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Конструктор копирования. Адаптер копирования построена с содержанием other.c. (объявлено неявно)
Original:
Copy constructor. The adaptor is copy-constructed with the contents of other.c. (объявлено неявно)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Переместить конструктор. Адаптер построен с std::move(other.c). (объявлено неявно)
Original:
Move constructor. The adaptor is constructed with std::move(other.c). (объявлено неявно)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5-9)
Следующие конструкторы определены только если std::uses_allocator<container_type, Alloc>::value == true, то есть, если основной контейнер-распределитель известно контейнер (справедливо для всех стандартных контейнеров библиотеки).
Original:
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).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Создает основного контейнера с помощью alloc как распределитель. Эффективно называет c(alloc).
Original:
Constructs the underlying container using alloc as allocator. Effectively calls c(alloc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Создает базового контейнера с содержимым cont и использовании alloc как распределитель. Эффективно называет c(cont, alloc).
Original:
Constructs the underlying container with the contents of cont and using alloc as allocator. Effectively calls c(cont, alloc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
Создает базового контейнера с содержимым cont использованием движение семантики при использовании alloc как распределитель. Эффективно называет c(std::move(cont), alloc).
Original:
Constructs the underlying container with the contents of cont using move semantics while utilising alloc as allocator. Effectively calls c(std::move(cont), alloc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
Создает адаптер с содержанием и использованием other.c alloc как распределитель. Эффективно называет c(athor.c, alloc).
Original:
Constructs the adaptor with the contents of other.c and using alloc as allocator. Effectively calls c(athor.c, alloc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
9)
Создает адаптер с содержанием other использованием движение семантики при использовании alloc как распределитель. Эффективно называет c(std::move(other.c), alloc).
Original:
Constructs the adaptor with the contents of other using move semantics while utilising alloc as allocator. Effectively calls c(std::move(other.c), alloc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Содержание

[править] Параметры

alloc -
распределителя использовать для всех выделения памяти базового контейнера
Original:
allocator to use for all memory allocations of the underlying container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
other -
другой контейнер адаптер для использования в качестве источника для инициализации базового контейнера
Original:
another container adaptor to be used as source to initialize the underlying container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cont -
Контейнер для использования в качестве источника для инициализации базового контейнера
Original:
container to be used as source to initialize the underlying container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
first, last -
диапазон элементов для инициализации с
Original:
range of elements to initialize with
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Требования, накладываемые на типы
-
Alloc должен соответствовать требованиям Allocator.
-
Container должен соответствовать требованиям Container. The constructors (5-10) are only defined if Container meets the requirements of AllocatorAwareContainer
-
InputIt должен соответствовать требованиям InputIterator.

[править] Сложность

1, 3, 5, 6, 8: линейный по cont или other
Original:
1, 3, 5, 6, 8: linear in cont or other
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2, 4, 7, 9: постоянная
Original:
2, 4, 7, 9: constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Пример

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

Вывод:

1
1
5

[править] См. также

Шаблон:tlist frontr
(public функция-член) [edit]