std::list<T,Allocator>:: list
|
list
(
)
:
list
(
Allocator
(
)
)
{
}
|
(1) |
(C++11부터)
(C++26부터 constexpr) |
| (2) | ||
|
explicit
list
(
const
Allocator
&
alloc
=
Allocator
(
)
)
;
|
(C++11 이전) | |
|
explicit
list
(
const
Allocator
&
alloc
)
;
|
(C++11 이후)
(C++26부터 constexpr) |
|
|
explicit
list
(
size_type count,
const Allocator & alloc = Allocator ( ) ) ; |
(3) |
(C++11부터)
(C++26부터 constexpr) |
| (4) | ||
|
explicit
list
(
size_type count,
const
T
&
value
=
T
(
)
,
const Allocator & alloc = Allocator ( ) ) ; |
(C++11 이전) | |
|
list
(
size_type count,
const
T
&
value,
const Allocator & alloc = Allocator ( ) ) ; |
(C++11 이후)
(C++26부터 constexpr) |
|
|
template
<
class
InputIt
>
list
(
InputIt first, InputIt last,
|
(5) | (C++26부터 constexpr) |
|
template
<
container-compatible-range
<
T
>
R
>
list
(
std::
from_range_t
, R
&&
rg,
|
(6) |
(C++23부터)
(C++26부터 constexpr) |
|
list
(
const
list
&
other
)
;
|
(7) | (C++26부터 constexpr) |
|
list
(
list
&&
other
)
;
|
(8) |
(C++11부터)
(C++26부터 constexpr) |
| (9) | ||
|
list
(
const
list
&
other,
const
Allocator
&
alloc
)
;
|
(C++11부터)
(C++23 이전까지) |
|
|
list
(
const
list
&
other,
const std:: type_identity_t < Allocator > & alloc ) ; |
(C++23부터)
(C++26부터 constexpr) |
|
| (10) | ||
|
list
(
list
&&
other,
const
Allocator
&
alloc
)
;
|
(C++11 이후)
(C++23 이전까지) |
|
|
list
(
list
&&
other,
const
std::
type_identity_t
<
Allocator
>
&
alloc
)
;
|
(C++23 이후)
(C++26 이후 constexpr) |
|
|
list
(
std::
initializer_list
<
T
>
init,
const Allocator & alloc = Allocator ( ) ) ; |
(11) |
(C++11 이후)
(C++26 이후 constexpr) |
다양한 데이터 소스로부터 새로운
list
를 생성하며, 선택적으로 사용자가 제공한 할당자
alloc
를 사용합니다.
list
를 생성합니다.
list
를 생성합니다.
T
객체를
count
개만큼 기본 생성하여
list
를 구성합니다. 복사는 발생하지 않습니다.
count
개의
value
값 요소 복사본으로
list
를 생성합니다.
|
|
(C++11부터) |
[
first
,
last
)
의 내용으로
list
를 생성합니다.
[
first
,
last
)
내의 각 반복자는 정확히 한 번 역참조됩니다.
|
만약
|
(C++11 이전) |
|
이 오버로드는
만약
|
(C++11 이후) |
list
를 생성합니다.
rg
내의 각 반복자는 정확히 한 번 역참조됩니다.
list
를
other
의 내용으로 생성합니다.
|
할당자는
std::
allocator_traits
<
Allocator
>
::
select_on_container_copy_construction
|
(C++11부터) |
list
를
other
의 내용으로 생성합니다. 할당자는
other.
get_allocator
(
)
로부터 이동 생성으로 얻습니다.
목차매개변수
복잡도
1,2)
상수.
3,4)
count
에 대해 선형적입니다.
5)
선형 시간,
std::
distance
(
first, last
)
.
6)
선형 시간 복잡도,
ranges::
distance
(
rg
)
.
7)
other.
size
(
)
에 선형적입니다.
8)
상수.
9)
other.
size
(
)
에 선형적입니다.
10)
other.
size
(
)
에 대해 선형 시간,
alloc
!
=
other.
get_allocator
(
)
인 경우, 그렇지 않으면 상수 시간.
11)
선형적으로
init.
size
(
)
.
예외Allocator :: allocate 호출은 예외를 던질 수 있습니다. 참고
컨테이너 이동 생성(오버로드 (8)) 후에 원래
예제
이 코드 실행
#include <iostream> #include <list> #include <string> template<typename T> std::ostream& operator<<(std::ostream& s, const std::list<T>& v) { s.put('{'); for (char comma[]{'\0', ' ', '\0'}; const auto& e : v) s << comma << e, comma[0] = ','; return s << "}\n"; } int main() { // C++11 초기화 리스트 구문: std::list<std::string> words1{"the", "frogurt", "is", "also", "cursed"}; std::cout << "1: " << words1; // words2 == words1 std::list<std::string> words2(words1.begin(), words1.end()); std::cout << "2: " << words2; // words3 == words1 std::list<std::string> words3(words1); std::cout << "3: " << words3; // words4는 {"Mo", "Mo", "Mo", "Mo", "Mo"} std::list<std::string> words4(5, "Mo"); std::cout << "4: " << words4; const auto rg = {"cat", "cow", "crow"}; #ifdef __cpp_lib_containers_ranges std::list<std::string> words5(std::from_range, rg); // 오버로드 (6) #else std::list<std::string> words5(rg.begin(), rg.end()); // 오버로드 (5) #endif std::cout << "5: " << words5; } 출력: 1: {the, frogurt, is, also, cursed}
2: {the, frogurt, is, also, cursed}
3: {the, frogurt, is, also, cursed}
4: {Mo, Mo, Mo, Mo, Mo}
5: {cat, cow, crow}
결함 보고서다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.
참고 항목
|