Skip to content

F.40 : "Use a lambda.." : incorrect assertion that function objects don't overload? #512

Open
@jmarathe1

Description

@jmarathe1

The text says:
"On the other hand, lambdas and function objects don't overload; if you need to overload, prefer a function..".

I was confused by this. The operator() for a "function object" is overloadable. e.g:

struct foo {
void operator()(int) { std::cout << "first" << std::endl; }
void operator()(double) { std::cout << "second" << std::endl; }
};

Can the text be clarified?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions