deduction guides for
std::stack
|
定義済みヘッダー
<stack>
|
||
|
template
<
class
Container
>
stack
(
Container
)
|
(1) | (C++17以降) |
|
template
<
class
Container,
class
Alloc
>
stack
(
Container, Alloc
)
|
(2) | (C++17以降) |
|
template
<
class
InputIt
>
stack
(
InputIt, InputIt
)
|
(3) | (C++23以降) |
|
template
<
class
InputIt,
class
Alloc
>
stack
(
InputIt, InputIt, Alloc
)
|
(4) | (C++23以降) |
|
template
<
ranges::
input_range
R
>
stack
(
std::
from_range_t
, R
&&
)
|
(5) | (C++23以降) |
|
template
<
ranges::
input_range
R,
class
Allocator
>
stack
(
std::
from_range_t
, R
&&
, Allocator
)
|
(6) | (C++23以降) |
これらの
デダクションガイド
は、
stack
が基となるコンテナ型からの推論を可能にするために提供されています。
これらのオーバーロードは、以下の条件でのみオーバーロード解決に参加します:
-
InputIt(存在する場合)は LegacyInputIterator を満たす、 -
Container(存在する場合)は Allocator を満たさない、 -
(3)
(until C++23)
(4)
(since C++23)
の場合、
Allocは Allocator を満たし、かつ -
std::
uses_allocator_v
<
Container, Alloc
>
が
true
である(
ContainerとAllocの両方が存在する場合)。
注意: ライブラリが型が
LegacyInputIterator
を満たさないと判断する程度は未規定であるが、少なくとも整数型は入力イテレータとして適格ではない。同様に、型が
Allocator
を満たさないと判断する程度は未規定であるが、少なくともメンバ型
Alloc::value_type
が存在しなければならず、式
std::
declval
<
Alloc
&
>
(
)
.
allocate
(
std::
size_t
{
}
)
が未評価オペランドとして扱われた場合に well-formed でなければならない。
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_adaptor_iterator_pair_constructor
|
202106L
|
(C++23) | std::queue および std::stack のイテレータペアコンストラクタ; オーバーロード (2) および (4) |
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | レンジ対応 の構築と挿入; オーバーロード (5) および (6) |
例
#include <stack> #include <vector> int main() { std::vector<int> v = {1, 2, 3, 4}; std::stack s{v}; // guide #1 deduces std::stack<int, vector<int>> }