std::list<T,Allocator>:: push_front
From cppreference.net
|
void
push_front
(
const
T
&
value
)
;
|
(1) | (constexpr since C++26) |
|
void
push_front
(
T
&&
value
)
;
|
(2) |
(C++11부터)
(constexpr since C++26) |
컨테이너의 시작 부분에 value 의 복사본을 추가합니다.
반복자나 참조가 무효화되지 않습니다.
목차 |
매개변수
| value | - | 맨 앞에 추가할 요소의 값 | ||
| 타입 요구사항 | ||||
-
|
||||
복잡도
상수.
예외
어떤 이유로든 예외가 발생하면, 이 함수들은 아무런 효과를 가지지 않습니다( strong exception safety guarantee ).
예제
이 코드 실행
#include <list> #include <iomanip> #include <iostream> #include <string> int main() { std::list<std::string> letters; letters.push_front("me"); // overload (1) std::string s{"send"}; letters.push_front(std::move(s)); // overload (2) std::cout << "std::list letters holds: "; for (auto&& e : letters) std::cout << std::quoted(e) << ' '; std::cout << "\nMoved-from string s holds: " << std::quoted(s) << '\n'; }
가능한 출력:
std::list letters holds: "send" "me" Moved-from string s holds: ""
참고 항목
|
(C++11)
|
시작 부분에 제자리에서 요소를 생성합니다
(public member function) |
|
끝에 요소를 추가합니다
(public member function) |
|
|
첫 번째 요소를 제거합니다
(public member function) |
|
|
인수에서 추론된 타입의
std::front_insert_iterator
를 생성합니다
(function template) |