Skip to content

Commit

Permalink
counted_iterator : P2259R1対応
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed Sep 26, 2023
1 parent 9e16741 commit 331a036
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions reference/iterator/counted_iterator.md
Expand Up @@ -15,24 +15,24 @@ namespace std {
};


// incrementable_traitsにアダプトする
template<class I>
struct incrementable_traits<counted_iterator<I>> {
using difference_type = iter_difference_t<I>;
};

// iterator_traitsにアダプトする
template<input_iterator I>
requires same_as<ITER_TRAITS(I), iterator_traits<I>>
struct iterator_traits<counted_iterator<I>> : iterator_traits<I> {
using pointer = void;
using pointer = conditional_t<contiguous_iterator<I>, add_pointer_t<iter_reference_t<I>>, void>;
};
}
```
* input_or_output_iterator[link /reference/iterator/input_or_output_iterator.md]
* incrementable_traits[link /reference/iterator/incrementable_traits.md]
* iter_difference_t[link /reference/iterator/iter_difference_t.md]
* input_iterator[link /reference/iterator/input_iterator.md]
* same_as[link /reference/concepts/same_as.md]
* ITER_CONCEPT[link /reference/iterator/input_iterator.md#iter_concept]
* iterator_traits[link /reference/iterator/iterator_traits.md]
* conditional_t[link /reference/type_traits/conditional.md]
* contiguous_iterator[link /reference/iterator/contiguous_iterator.md]
* add_pointer_t[link /reference/type_traits/add_pointer.md]
* iter_reference_t[link /reference/iterator/iter_reference_t.md]
## 概要
`counted_iterator`は、イテレータをラップしてそこから指定されたカウント数の範囲を表現するイテレータアダプタである。
Expand All @@ -50,6 +50,7 @@ namespace std {
| [`base`](counted_iterator/base.md) | 元のイテレータを取得する | C++20 |
| [`count`](counted_iterator/count.md) | 代入演算子 | C++20 |
| [`operator*`](counted_iterator/op_deref.md) | 間接参照演算子 | C++20 |
| [`operator->`](counted_iterator/op_arrow.md.nolink) | メンバアクセス演算子 | C++20 |
| [`operator++`](counted_iterator/op_increment.md) | イテレータをインクリメントする | C++20 |
| [`operator--`](counted_iterator/op_decrement.md) | イテレータをデクリメントする | C++20 |
| [`operator+`](counted_iterator/op_plus.md) | イテレータを進める | C++20 |
Expand Down Expand Up @@ -77,9 +78,15 @@ namespace std {
## メンバ型
| 名前 | 説明 | 対応バージョン |
|-----------------|-----|-------|
| `iterator_type` | `I` | C++20 |
|---------------------|-----|-------|
| `iterator_type` | `I` | C++20 |
| `value_type` | [`iter_value_t`](/reference/iterator/iter_value_t.md)`<I>`※1 | C++20 |
| `difference_type` | [`iter_difference_t`](/reference/iterator/iter_difference_t.md)`<I>` | C++20 |
| `iterator_concept` | `typename I::iterator_concept`※2 | C++20 |
| `iterator_category` | `typename I::iterator_category`※2 | C++20 |
- ※1 `I`が[`indirectly_readable`](/reference/iterator/indirectly_readable.md)のモデルである場合にのみ定義される
- ※2 どちらも、対応するメンバ型が定義されている場合にのみ定義される
## 例
Expand Down Expand Up @@ -136,3 +143,4 @@ int main() {
## 参照
- [P0896R4 The One Ranges Proposal (was Merging the Ranges TS)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0896r4.pdf)
- [Hidden Friends - yohhoyの日記](https://yohhoy.hatenadiary.jp/entry/20190531/p1)
- [P2259R1 Repairing input range adaptors and `counted_iterator`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2259r1.html)

0 comments on commit 331a036

Please sign in to comment.