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

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

من cppreference.com
void push_back( const T& value );
(1) قالب:mark since none
void push_back( T&& value );
(2) (since C++11)

Appends the given element ‎value‎ to the end of the container.

1) The new element is initialized as a copy of ‎value‎.
2) ‎value‎ is moved into the new element.

Information on iterator invalidation is copied from here

محتويات

[تعديل] Parameters

value - the value of the element to append

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

[تعديل] Return value

(none)

[تعديل] Complexity

قالب:included

[تعديل] Exceptions

If an exception is thrown, this function has no effect (strong exception guarantee).


[تعديل] Example

The following code uses ‎push_back‎ to add several integers to a std::{{{1}}}<int>:

#include <{{{1}}}>
#include <iostream>
 
int main()
{
    std::{{{1}}}<int> numbers;
 
    numbers.push_back(42);
    numbers.push_back(314159); 
 
    for (int i : numbers) { // c++11 range-based for loop
        std::cout << i << '\n';
    } 
 
    return 0;
}

الخرج:

42
314159

[تعديل] See also

قالب:dsc mem funقالب:dsc mem funقالب:dsc mem fun