I tried to figure out -out there- a good technical reason for defining a class that contains only one member, and that member is operator().
I stumbled on who -for regardless of reason- created a namespace containing a couple of classes, but each class contains only one operator()as a member.
It is clear to me that these classes can then be used as if they were methods (very likely), but why is this a good technical approach (I believe it is good), and not just defining a set of different methods inside the singleton class, which in this the specific case will belong to the namespace that I mentioned above.
The namespace looks something like this:
namespace myNamespace {
class ClassA {
public:
void operator()();
};
class ClassB {
public:
int operator()(arg1, arg2);
};
...
}
Is it just a matter of personal taste / style or is it an expression of advanced / sophisticated design? I assume that this design includes some wise knowledge that I have not yet collected, but on the other hand, I have not found a single article or question discussing this - which makes me doubt such "wise knowledge" in design.
What do experts say here?
Thank you in advance!
EDIT
Hello again! I accept this question as a REPEAT question, the answer to which can be found here .
The term "Functor" was unknown to me, and, trying to find an answer to my doubts (before submitting this question), I did not see any references to this term.
SergeyA, , - . -from view- , , .
!