Boost logo

Boost Users :

Subject: Re: [Boost-users] comparing objects using boost
From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-09-05 15:41:07


On Fri, Sep 05, 2008 at 02:28:39PM -0500, Annamalai Gurusami wrote:
> On Fri, Sep 5, 2008 at 12:47 PM, Reena Dass <Reena.Dass_at_[hidden]> wrote:
> > Is there something available to compare objects using boost, similar to
> > java.lang.Object Equals?
>
> I think this question is better directed at C++ groups (like
> comp.lang.c++.moderated). From your question it is not clear what
> exactly you are looking for.
>
My guess: Java has single object hierarchy with Object at the root. So,
all object instances are in a sense "comparable" (yes, it is allowed to
compare Apples and Oranges, and, depending on the definition of Equals in
derived classes, you might end up with an Apple being equal to an Orange).

You can have the same behavior in C++ by using multiple inheritance to derive
all your objects from Comparable:

struct Comparable {
  virtual bool equals(const Comparable&) const = 0;
};


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net