Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# begin | ||
* ranges[meta header] | ||
* std::ranges[meta namespace] | ||
* as_const_view[meta class] | ||
* function[meta id-type] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
constexpr auto begin() requires (!simple-view<V>); // (1) | ||
constexpr auto begin() const requires range<const V>; // (2) | ||
``` | ||
* simple-view[link /reference/ranges/simple-view.md] | ||
* range[link /reference/ranges/range.md] | ||
## 概要 | ||
`view`の先頭要素を指すイテレータを取得する。 | ||
## 戻り値 | ||
入力`view`(`V`)のオブジェクトを`base_`というメンバに保持するとして、(1)(2)どちらも | ||
```cpp | ||
return ranges::cbegin(base_); | ||
``` | ||
* cbegin[link /reference/ranges/cbegin.md] | ||
|
||
## 例 | ||
|
||
```cpp example | ||
#include <ranges> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
int main() { | ||
std::vector<int> vec = {1, 2, 3, 4, 5}; | ||
|
||
std::ranges::as_const_view acv{vec}; | ||
|
||
auto it = acv.begin(); | ||
|
||
std::cout << *it << '\n'; | ||
|
||
++it; | ||
std::cout << *it << '\n'; | ||
|
||
// 書き換え不可 | ||
//*it = 0; | ||
} | ||
``` | ||
* begin[color ff0000] | ||
|
||
### 出力 | ||
|
||
``` | ||
1 | ||
2 | ||
``` | ||
|
||
## バージョン | ||
### 言語 | ||
- C++23 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): 13.1 | ||
- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 | ||
|
||
## 参照 | ||
|
||
- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# end | ||
* ranges[meta header] | ||
* std::ranges[meta namespace] | ||
* as_const_view[meta class] | ||
* function[meta id-type] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
constexpr auto end() requires (!simple-view<V>); // (1) | ||
constexpr auto end() const requires range<const V>; // (2) | ||
``` | ||
* simple-view[link /reference/ranges/simple-view.md] | ||
* range[link /reference/ranges/range.md] | ||
## 概要 | ||
`view`の番兵を取得する。 | ||
## 戻り値 | ||
入力`view`(`V`)のオブジェクトを`base_`というメンバに保持するとして、(1)(2)どちらも | ||
```cpp | ||
return ranges::cend(base_); | ||
``` | ||
* cend[link /reference/ranges/cend.md] | ||
|
||
## 例 | ||
|
||
```cpp example | ||
#include <ranges> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
int main() { | ||
std::vector<int> vec = {1, 2, 3, 4, 5}; | ||
|
||
std::ranges::as_const_view acv{vec}; | ||
|
||
auto it = acv.begin(); | ||
auto se = acv.end(); | ||
|
||
assert(it != se); | ||
|
||
--se; | ||
|
||
std::cout << *se << '\n' | ||
} | ||
``` | ||
* begin[color ff0000] | ||
* subrange[link /reference/ranges/subrange.md] | ||
|
||
### 出力 | ||
|
||
``` | ||
5 | ||
``` | ||
|
||
## バージョン | ||
### 言語 | ||
- C++23 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): 13.1 | ||
- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 | ||
|
||
## 参照 | ||
|
||
- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html) |