Boost logo

Boost Users :

Subject: Re: [Boost-users] Equality comparison of boost::function<>
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2009-09-02 11:16:01


Comparing the types and internal memory of objects is a non-starter -
an empty class is absolutley not the same as a stateless class. Take a
look at this example of an empty class with state.

//empty_class.hpp
class empty_class
{
public:
  empty_class();
  empty_class(empty_class& other);

  int operator()()const;
};

//empty_class.cpp
namespace
{
  static std::map<const empty_class*const,int> map_;
  static int next_ = 0;
}

empty_class::empty_class()
{
  map_[this] = next_++;
}

empty_class::empty_class(const empty_class& other)
{
  map_[this] = next_++;
}

int empty_class::operator()()const
{
  return map_[this];
}


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