Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lformaggia authored Oct 25, 2024
1 parent b68a5dd commit 70d38c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Examples/src/STL/RangesAndViews/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Yet, they can still work with an iterator-sentinel pair if needed, offering flex
```
- **Projections**: Projections allow for more sophisticated operations by transforming elements before processing them in the algorithm.
The are implemented as an additional and optional argument.
They are implemented as an additional and optional argument.
```cpp
// Traditional algorithm to sort by absolute values
Expand All @@ -104,9 +104,10 @@ Yet, they can still work with an iterator-sentinel pair if needed, offering flex
Projection can also be adopted to specify the element used in the algorithm. For instance, in the following example, we sort a vector of pairs by the second element of the pair:

```cpp
std::vector<std::pair<int, int>> v = {{1, 2}, {2, 1}, {3, 3}};
std::vector<std::pair<int, int>> v = { {1, 2}, {2, 1}, {3, 3} };
std::ranges::sort(v, {}, [](auto p) { return p.second; });
```
- **Pointer-to-Member Callables**: These algorithms support pointer-to-member callables, which can specify operations on member variables of class objects within a range.
An example:
```cpp
Expand Down

0 comments on commit 70d38c5

Please sign in to comment.