bind and mem_fn now support operator== and operator!=

[SVN r21978]
This commit is contained in:
Peter Dimov
2004-01-26 19:13:17 +00:00
parent f91de70d8e
commit ea8c0ef25e
9 changed files with 1021 additions and 2 deletions
+100
View File
@@ -69,6 +69,18 @@ template<class F> struct result_traits< unspecified, reference_wrapper<F> >
#endif
// ref_compare
template<class T> bool ref_compare(T const & a, T const & b, long)
{
return a == b;
}
template<class T> bool ref_compare(reference_wrapper<T> const & a, reference_wrapper<T> const & b, int)
{
return a.get_pointer() == b.get_pointer();
}
// bind_t forward declaration for listN
template<class R, class F, class L> class bind_t;
@@ -84,6 +96,11 @@ public:
T & get() { return t_; }
T const & get() const { return t_; }
bool operator==(value const & rhs) const
{
return t_ == rhs.t_;
}
private:
T t_;
@@ -157,6 +174,11 @@ public:
{
}
bool operator==(list0 const &) const
{
return true;
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -203,6 +225,11 @@ public:
BOOST_BIND_VISIT_EACH(v, a1_, 0);
}
bool operator==(list1 const & rhs) const
{
return ref_compare(a1_, rhs.a1_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -257,6 +284,11 @@ public:
BOOST_BIND_VISIT_EACH(v, a2_, 0);
}
bool operator==(list2 const & rhs) const
{
return ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -315,6 +347,11 @@ public:
BOOST_BIND_VISIT_EACH(v, a3_, 0);
}
bool operator==(list3 const & rhs) const
{
return ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -377,6 +414,13 @@ public:
BOOST_BIND_VISIT_EACH(v, a4_, 0);
}
bool operator==(list4 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -443,6 +487,13 @@ public:
BOOST_BIND_VISIT_EACH(v, a5_, 0);
}
bool operator==(list5 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -513,6 +564,13 @@ public:
BOOST_BIND_VISIT_EACH(v, a6_, 0);
}
bool operator==(list6 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -587,6 +645,14 @@ public:
BOOST_BIND_VISIT_EACH(v, a7_, 0);
}
bool operator==(list7 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
ref_compare(a7_, rhs.a7_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -665,6 +731,14 @@ public:
BOOST_BIND_VISIT_EACH(v, a8_, 0);
}
bool operator==(list8 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
ref_compare(a7_, rhs.a7_, 0) && ref_compare(a8_, rhs.a8_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -747,6 +821,14 @@ public:
BOOST_BIND_VISIT_EACH(v, a9_, 0);
}
bool operator==(list9 const & rhs) const
{
return
ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
ref_compare(a7_, rhs.a7_, 0) && ref_compare(a8_, rhs.a8_, 0) && ref_compare(a9_, rhs.a9_, 0);
}
#ifdef BOOST_NO_VOID_RETURNS
template<class R> struct evaluator
@@ -963,6 +1045,8 @@ template<class R, class F, class L> class bind_t
{
public:
typedef bind_t this_type;
bind_t(F f, L const & l): f_(f), l_(l) {}
#define BOOST_BIND_EVALUATE return l_(type<result_type>(), f_, a)
@@ -980,6 +1064,8 @@ template<class F, class L> class implementation
{
public:
typedef implementation this_type;
implementation(F f, L const & l): f_(f), l_(l) {}
#define BOOST_BIND_EVALUATE return L::BOOST_NESTED_TEMPLATE evaluator<result_type>::type::eval(l_, f_, a);
@@ -1001,6 +1087,8 @@ private:
public:
typedef implementation this_type;
implementation(F f, L const & l): f_(f), l_(l) {}
#define BOOST_BIND_EVALUATE L::BOOST_NESTED_TEMPLATE evaluator<result_type>::type::eval(l_, f_, a);
@@ -1021,6 +1109,18 @@ public:
#endif
// bind_t::operator==
template<class R, class F, class L> bool operator==(bind_t<R, F, L> const & a, bind_t<R, F, L> const & b)
{
return a.compare(b);
}
template<class R, class F, class L> bool operator!=(bind_t<R, F, L> const & a, bind_t<R, F, L> const & b)
{
return !a.compare(b);
}
// add_value
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)