Skip to content

Commit

Permalink
Demo the pointer-to-reference view.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvc1989 committed Dec 20, 2023
1 parent 5c08eee commit 987134b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions programming/languages/cpp/template/concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,5 +471,14 @@ int main() {
std::cout << score << ' ';
}
std::cout << '\n'; // print 400 300 500 200 100
auto range_of_score_ref = range_of_score_ptr
| std::views::transform([](int *i) -> int & { return *i; });
for (int &score_ref : range_of_score_ref) {
score_ref /= 10;
}
for (int score : range_of_score) {
std::cout << score << ' ';
}
std::cout << '\n'; // print 40 30 50 20 10
}
```

0 comments on commit 987134b

Please sign in to comment.