Vladimir Grigoriev
2010-01-21 10:52:12 UTC
Let consider an example.
There is a class named Person. And it has a member size_t personalID and an
equality operator
bool operator ==( const Person &lhs, size_t targetID );
However there is not a Person constructor with one argument equal to size_t
as a personal ID.
So there is the above equality operator and there is no a reverse equality
operator as
bool operator ==( size_t targetID, const Personal &rhs ); // invalid
Let assume further that some persons with personal IDs which belong to a
range of personal IDs (a simple array) have gotten a bonus. And we are going
to check which persons of some department are among them.
What should we to do? Shoot ourselves?
Our attempt to use the algorithm std::find_first_of is prohibited by the
Standard which requires equality comparability.
So main area of classes and objects are overboard of STD algorithms. At the
same time there is not something in the definition of find algorithms that
prevents to use them with classes which have an equality operator which does
not satisfies the requirements
if a == b then must be b == a
Vladimir Grigoriev
There is a class named Person. And it has a member size_t personalID and an
equality operator
bool operator ==( const Person &lhs, size_t targetID );
However there is not a Person constructor with one argument equal to size_t
as a personal ID.
So there is the above equality operator and there is no a reverse equality
operator as
bool operator ==( size_t targetID, const Personal &rhs ); // invalid
Let assume further that some persons with personal IDs which belong to a
range of personal IDs (a simple array) have gotten a bonus. And we are going
to check which persons of some department are among them.
What should we to do? Shoot ourselves?
Our attempt to use the algorithm std::find_first_of is prohibited by the
Standard which requires equality comparability.
So main area of classes and objects are overboard of STD algorithms. At the
same time there is not something in the definition of find algorithms that
prevents to use them with classes which have an equality operator which does
not satisfies the requirements
if a == b then must be b == a
Vladimir Grigoriev