Skip to content

Commit b3ffb71

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#124 from LegalizeAdulthood/patch-1
Format functor class example
2 parents 2a5d0e9 + 8ce9792 commit b3ffb71

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ A *function object*, or *functor*, is any type that implements operator(). This
2323
## Creating a Function Object
2424
To create a function object, create a type and implement operator(), such as:
2525

26+
```
2627
class Functor
27-
{
28-
public:
29-
int operator()(int a, int b)
30-
{
31-
return a <b;
32-
}
33-
};
34-
28+
{
29+
public:
30+
int operator()(int a, int b)
31+
{
32+
return a < b;
33+
}
34+
};
35+
```
36+
3537
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 is 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.
3638

3739
## Function Objects and Containers

0 commit comments

Comments
 (0)