I have 2 questions in my journey to understanding functors in C++.
I was reading the answer to this question and looked at the example and couldn't see the difference between functors and constructors with the exception of a having a return type.
Would the functor's state and behavior be replicated with just the combination of a constructor and an instance method? The instance method would have a return type. The example already has a constructor hence the functor doesn't add much. Isn't the functor also an instance method?
Wouldn't you just need
auto
to make it confusing to figure out if you are dealing with a function or constructor?
add_x add42(42);
// somewhere deeper in the code
auto X = add42(8);