- iterator[meta header]
- std[meta namespace]
- move_sentinel[meta class]
- function[meta id-type]
- cpp20[meta cpp]
constexpr move_sentinel(); // (1)
constexpr explicit move_sentinel(S s); // (2)
template<class S2>
requires convertible_to<const S2&, S>
constexpr move_sentinel(const move_sentinel<S2>& s); // (3)
- convertible_to[link /reference/concepts/convertible_to.md]
move_sentinel
オブジェクトを構築する。
S
の番兵オブジェクトをlast
というメンバ変数に保持しているとする。
- (1) :
last
を値初期化する(last{}
相当の初期化)。 - (2) :
last
をstd::move(s)
によって初期化する。 - (3) :
last
をs.last
によって初期化する。
- (1) :
is_trivially_default_constructible_v
<S> == true
の時。
#include <iterator>
#include <vector>
int main() {
std::vector<int> vec = {1, 2, 3};
auto se = std::end(vec);
// (1) デフォルト構築
std::move_sentinel<std::vector<int>::iterator> ms1{};
// (2) 番兵を渡して構築
std::move_sentinel ms2{se};
// (3) コピー構築
std::move_sentinel<std::vector<int>::iterator> ms3{ms2};
}
- std::move_sentinel[color ff0000]
- C++20
- Clang: ??
- GCC: 10.1 [mark verified]
- Visual C++: 2019 Update 7 [mark verified]