Skip to content

Commit f8ed85f

Browse files
authored
Improve example in "Function Objects in the C++ Standard Library" article
1 parent ce4459d commit f8ed85f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/standard-library/function-objects-in-the-stl.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ Function objects provide two main advantages over a regular function call. The f
1616
To create a function object, create a type and implement `operator()`, such as:
1717

1818
```cpp
19-
class Functor
19+
class LessThanFunctor
2020
{
2121
public:
22-
int operator()(int a, int b)
22+
bool operator()(int a, int b)
2323
{
2424
return a < b;
2525
}
2626
};
2727

2828
int main()
2929
{
30-
Functor f;
30+
LessThanFunctor less_than;
3131
int a = 5;
3232
int b = 7;
33-
int ans = f(a, b);
33+
bool ans = less_than(a, b);
3434
}
3535
```
3636

37-
The last line of the `main` function shows how you call the function object. This call looks like a call to a function, but it's actually calling `operator()` of the `Functor` type. This similarity between calling a function object and a function is how the term function object came about.
37+
The last line of the `main` function shows how you call the function object. This call looks like a call to a function, but it's actually calling `operator()` of the `LessThanFunctor` type. This similarity between calling a function object and a function is how the term function object came about.
3838

3939
## Function Objects and Containers
4040

0 commit comments

Comments
 (0)