std::ranges::subrange
的推導指南
來自 cppreference.com
定義於標頭檔案 <ranges> |
||
template< std::input_or_output_iterator I, std::sentinel_for<I> S > subrange(I, S) -> subrange<I, S>; |
(1) | (C++20 起) |
template< std::input_or_output_iterator I, std::sentinel_for<I> S > subrange(I, S, /*make-unsigned-like-t*/<std::iter_difference_t<I>>) -> |
(2) | (C++20 起) |
template< ranges::borrowed_range<R> > subrange(R&&) -> |
(3) | (C++20 起) |
template< ranges::borrowed_range<R> > subrange(R&&, /*make-unsigned-like-t*/<ranges::range_difference_t<R>>) -> |
(4) | (C++20 起) |
這些推導指南用於 std::ranges::subrange。
2) 從迭代器和哨兵的型別推匯出模板實參,同時指定了範圍的大小。
subrange
總是帶大小的。3) 從範圍的型別推匯出模板實參。如果可以從範圍或其迭代器和哨兵獲得大小,則
subrange
是有大小的。4) 從範圍的型別推匯出模板實參,同時指定了範圍的大小。
subrange
總是帶大小的。有關 /* make-unsigned-like-t */ 的定義,請參閱 make-unsigned-like-t
。
[編輯] 注意
構造 subrange
物件時,
- 對於 (1,2),如果迭代器-哨兵對不表示有效範圍,則行為未定義。
- 對於 (2,4),如果給定大小不等於範圍的大小,則行為未定義。
[編輯] 示例
本節不完整 原因:無示例 |
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 3404 | C++20 | 提供了無意義的 pair-like 型別推導指南 | 已移除 |