deque::emplace
Inserts an element constructed in place into the deque at a specified position.
iterator emplace(
const_iterator _Where,
Type&& _Val
);
매개 변수
Parameter |
설명 |
_Where |
The position in the deque 클래스 where the first element is inserted. |
_Val |
The value of the element being inserted into the deque. |
반환 값
The function returns an iterator that points to the position where the new element was inserted into the deque.
설명
Any insertion operation can be expensive, see deque for a discussion of deque performance.
예제
// deque_emplace.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
int main( )
{
using namespace std;
deque <int> v1;
deque <int>::iterator Iter;
v1.push_back( 10 );
v1.push_back( 20 );
v1.push_back( 30 );
cout << "v1 =" ;
for ( Iter = v1.begin( ) ; Iter != v1.end( ) ; Iter++ )
cout << " " << *Iter;
cout << endl;
// initialize a deque of deques by moving v1
deque < deque <int> > vv1;
vv1.emplace( vv1.begin(), move( v1 ) );
if ( vv1.size( ) != 0 && vv1[0].size( ) != 0 )
{
cout << "vv1[0] =";
for (Iter = vv1[0].begin( ); Iter != vv1[0].end( ); Iter++ )
cout << " " << *Iter;
cout << endl;
}
}
요구 사항
헤더: <deque>
네임스페이스: std