- ranges[meta header]
- std::ranges[meta namespace]
- type-alias[meta id-type]
- cpp20[meta cpp]
namespace std::ranges {
template<range R>
using sentinel_t = decltype(ranges::end(declval<R&>()));
}
- range[link range.md]
- declval[link /reference/utility/declval.md]
- ranges::end[link end.md]
任意のRange型R
の番兵の型を取得する。
#include <ranges>
#include <vector>
int main() {
static_assert(std::same_as<std::ranges::sentinel_t<std::vector<int>>, std::vector<int>::iterator>);
}
- std::ranges::sentinel_t[color ff0000]
- C++20
- Clang: 13.0.0 [mark verified]
- GCC: 10.1.0 [mark verified]
- ICC: ?
- Visual C++: 2019 Update 10 [mark verified]