Skip to content

Commit

Permalink
transform_view: 例を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsurom committed Feb 25, 2024
1 parent 5ae4982 commit badecd6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions reference/ranges/transform_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,40 @@ int main() {
149
```

## 例 特定のメンバを選択する

```cpp example
#include <ranges>
#include <string>
#include <iostream>

struct Record {
int id = 0;
std::string name;
};

int main() {
using namespace std;
Record records[] = {
{1, "Alice"},
{2, "Bob"},
{3, "Charlie"}
};

for (int id : records | views::transform(&Record::id)) {
cout << id << '\n';
}
}
```
* views::transform[color ff0000]
### 出力
```
1
2
3
```
## バージョン
### 言語
- C++20
Expand Down

0 comments on commit badecd6

Please sign in to comment.