forked from cpprefjp/site
-
Notifications
You must be signed in to change notification settings - Fork 0
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
20 changed files
with
1,134 additions
and
24 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
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 @@ | ||
# base | ||
* ranges[meta header] | ||
* std::ranges[meta namespace] | ||
* filter_view[meta class] | ||
* function[meta id-type] | ||
* cpp20[meta cpp] | ||
|
||
```cpp | ||
constexpr V base() const & requires copy_constructible<V>; // (1) | ||
constexpr V base() &&; // (2) | ||
``` | ||
|
||
## 概要 | ||
|
||
メンバ変数として保持している、元の`view`を取得する。 | ||
|
||
## 効果 | ||
|
||
入力`view`(`V`)のオブジェクトを`base_`というメンバに保持するとして | ||
|
||
- (1) : `return base_;` と等しい | ||
- (2) : `return std::move(base_);` と等しい | ||
|
||
## 例 | ||
|
||
```cpp example | ||
#include <ranges> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
int main() { | ||
using std::ranges::view; | ||
|
||
std::vector<int> vec = {1, 2, 3, 4, 5}; | ||
|
||
std::ranges::filter_view fv{vec, [](int i) { return i % 2 == 0; }}; | ||
|
||
// (1) コピーして取得 | ||
view auto b1 = fv.base(); | ||
|
||
// (2) ムーブして取得 | ||
view auto b2 = std::move(fv).base(); | ||
|
||
// 得られるのは元のRangeではなく、あくまでview | ||
static_assert(not std::same_as<decltype(b1), std::vector<int>>); | ||
static_assert( std::same_as<decltype(b1), std::ranges::ref_view<std::vector<int>>>); | ||
static_assert( std::same_as<decltype(b2), std::ranges::ref_view<std::vector<int>>>); | ||
} | ||
``` | ||
* base[color ff0000] | ||
* filter_view[link ../filter_view.md] | ||
|
||
### 出力 | ||
|
||
``` | ||
``` | ||
|
||
## バージョン | ||
### 言語 | ||
- C++20 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): 13.0.0 [mark verified] | ||
- [GCC](/implementation.md#gcc): 10.1.0 [mark verified] | ||
- [ICC](/implementation.md#icc): ? | ||
- [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] | ||
|
||
## 参照 | ||
- [N4861 24.7.4 Filter view](https://timsong-cpp.github.io/cppwp/n4861/range.filter) | ||
- [N4950 26.7.8 Filter view](https://timsong-cpp.github.io/cppwp/n4950/range.filter) |
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,65 @@ | ||
# begin | ||
* ranges[meta header] | ||
* std::ranges[meta namespace] | ||
* filter_view[meta class] | ||
* function[meta id-type] | ||
* cpp20[meta cpp] | ||
|
||
```cpp | ||
constexpr iterator begin(); | ||
``` | ||
* iterator[link iterator.md] | ||
|
||
## 概要 | ||
|
||
`view`の先頭要素を指すイテレータを取得する。 | ||
|
||
## 事前条件 | ||
|
||
`pred_.`[`has_value`](/reference/optional/optional/has_value.md)`()`が`true`であること。 | ||
|
||
## 戻り値 | ||
|
||
`{*this, `[`ranges::find_if`](/reference/algorithm/ranges_find_if.md)`(base_, `[`ref`](/reference/functional/ref.md)`(*pred_))}` | ||
|
||
[`range`](../range.md)のモデルとなるためにはこの関数が償却定数時間で実行できなければならないため、値はキャッシュされる。 | ||
|
||
## 例 | ||
|
||
```cpp example | ||
#include <ranges> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
int main() { | ||
std::vector<int> vec = {1, 2, 3, 4, 5}; | ||
|
||
std::ranges::filter_view fv{vec, [](int i) { return i % 2 == 0; }}; | ||
|
||
auto it = fv.begin(); | ||
|
||
std::cout << *it << '\n'; | ||
} | ||
``` | ||
* begin[color ff0000] | ||
* filter_view[link ../filter_view.md] | ||
|
||
### 出力 | ||
|
||
``` | ||
2 | ||
``` | ||
|
||
## バージョン | ||
### 言語 | ||
- C++20 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): 13.0.0 [mark verified] | ||
- [GCC](/implementation.md#gcc): 10.1.0 [mark verified] | ||
- [ICC](/implementation.md#icc): ? | ||
- [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] | ||
|
||
## 参照 | ||
- [N4861 24.7.4 Filter view](https://timsong-cpp.github.io/cppwp/n4861/range.filter) | ||
- [N4950 26.7.8 Filter view](https://timsong-cpp.github.io/cppwp/n4950/range.filter) |
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,64 @@ | ||
# end | ||
* ranges[meta header] | ||
* std::ranges[meta namespace] | ||
* filter_view[meta class] | ||
* function[meta id-type] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
constexpr auto end() { | ||
if constexpr (common_range<V>) | ||
return iterator{*this, ranges::end(base_)}; | ||
else | ||
return sentinel{*this}; | ||
} | ||
``` | ||
* ranges::end[link ../end.md] | ||
* iterator[link iterator.md] | ||
* sentinel[link sentinel.md] | ||
|
||
## 概要 | ||
|
||
番兵を取得する。 | ||
|
||
## 例 | ||
|
||
```cpp example | ||
#include <ranges> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
int main() { | ||
std::vector<int> vec = {1, 2, 3, 4, 5}; | ||
|
||
std::ranges::filter_view fv{vec, [](int i) { return i % 2 == 0; }}; | ||
|
||
auto e = fv.end(); | ||
|
||
--e; | ||
|
||
std::cout << *e << '\n'; | ||
} | ||
``` | ||
* end[color ff0000] | ||
* filter_view[link ../filter_view.md] | ||
|
||
### 出力 | ||
|
||
``` | ||
4 | ||
``` | ||
|
||
## バージョン | ||
### 言語 | ||
- C++20 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): 13.0.0 [mark verified] | ||
- [GCC](/implementation.md#gcc): 10.1.0 [mark verified] | ||
- [ICC](/implementation.md#icc): ? | ||
- [Visual C++](/implementation.md#visual_cpp): 2019 Update 10 [mark verified] | ||
|
||
## 参照 | ||
- [N4861 24.7.4 Filter view](https://timsong-cpp.github.io/cppwp/n4861/range.filter) | ||
- [N4950 26.7.8 Filter view](https://timsong-cpp.github.io/cppwp/n4950/range.filter) |
Oops, something went wrong.