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)
+5
View File
@@ -27,6 +27,11 @@ template<int I> class arg
{
};
template<int I> bool operator==(arg<I> const &, arg<I> const &)
{
return true;
}
} // namespace boost
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
+5
View File
@@ -151,6 +151,11 @@
l_.accept(v);
}
bool compare(this_type const & rhs) const
{
return ref_compare(f_, rhs.f_, 0) && l_ == rhs.l_;
}
private:
F f_;
+180
View File
@@ -55,6 +55,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)();
}
bool operator==(BOOST_MEM_FN_NAME(mf0) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf0) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf0
@@ -94,6 +104,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)();
}
bool operator==(BOOST_MEM_FN_NAME(cmf0) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf0) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf1
@@ -139,6 +159,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1);
}
bool operator==(BOOST_MEM_FN_NAME(mf1) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf1) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf1
@@ -179,6 +209,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1);
}
bool operator==(BOOST_MEM_FN_NAME(cmf1) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf1) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf2
@@ -222,6 +262,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
}
bool operator==(BOOST_MEM_FN_NAME(mf2) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf2) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf2
@@ -260,6 +310,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
}
bool operator==(BOOST_MEM_FN_NAME(cmf2) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf2) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf3
@@ -303,6 +363,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
}
bool operator==(BOOST_MEM_FN_NAME(mf3) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf3) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf3
@@ -341,6 +411,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
}
bool operator==(BOOST_MEM_FN_NAME(cmf3) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf3) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf4
@@ -384,6 +464,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
}
bool operator==(BOOST_MEM_FN_NAME(mf4) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf4) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf4
@@ -422,6 +512,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
}
bool operator==(BOOST_MEM_FN_NAME(cmf4) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf4) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf5
@@ -465,6 +565,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
}
bool operator==(BOOST_MEM_FN_NAME(mf5) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf5) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf5
@@ -503,6 +613,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
}
bool operator==(BOOST_MEM_FN_NAME(cmf5) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf5) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf6
@@ -546,6 +666,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
}
bool operator==(BOOST_MEM_FN_NAME(mf6) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf6) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf6
@@ -584,6 +714,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
}
bool operator==(BOOST_MEM_FN_NAME(cmf6) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf6) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf7
@@ -627,6 +767,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
bool operator==(BOOST_MEM_FN_NAME(mf7) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf7) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf7
@@ -665,6 +815,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
bool operator==(BOOST_MEM_FN_NAME(cmf7) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf7) const & rhs) const
{
return f_ != rhs.f_;
}
};
// mf8
@@ -708,6 +868,16 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
bool operator==(BOOST_MEM_FN_NAME(mf8) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(mf8) const & rhs) const
{
return f_ != rhs.f_;
}
};
// cmf8
@@ -751,5 +921,15 @@ public:
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
bool operator==(BOOST_MEM_FN_NAME(cmf8) const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(BOOST_MEM_FN_NAME(cmf8) const & rhs) const
{
return f_ != rhs.f_;
}
};
+10
View File
@@ -308,6 +308,16 @@ public:
{
return (t.*f_);
}
bool operator==(dm const & rhs) const
{
return f_ == rhs.f_;
}
bool operator!=(dm const & rhs) const
{
return f_ != rhs.f_;
}
};
} // namespace _mfi