다음을 통해 공유


deque::at

Returns a reference to the element at a specified location in the deque.

reference at( 
   size_type _Pos 
); 
const_reference at( 
   size_type _Pos 
) const;

매개 변수

  • _Pos
    The subscript (or position number) of the element to reference in the deque.

반환 값

If _Pos is greater than the size of the deque, at throws an exception.

반환 값

If the return value of at is assigned to a const_reference, the deque object cannot be modified. If the return value of at is assigned to a reference, the deque object can be modified.

예제

// deque_at.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
{
   using namespace std;
   deque <int> c1;
   
   c1.push_back( 10 );
   c1.push_back( 20 );

   const int& i = c1.at( 0 );
   int& j = c1.at( 1 );
   cout << "The first element is " << i << endl;
   cout << "The second element is " << j << endl;
}
  

요구 사항

헤더: <deque>

네임스페이스: std

참고 항목

참조

deque 클래스

deque::operator[] 및 deque::at

표준 템플릿 라이브러리