equality comparisons on function erasure objects covered

...well, as good as possible, as boost refuses to implement this feature
This commit is contained in:
Fischlurch 2009-10-05 01:38:35 +02:00
parent 231278bafe
commit fea85acd0e
2 changed files with 19 additions and 5 deletions

View file

@ -184,7 +184,9 @@ namespace typelist{
operator== (StoreFunPtr const& o1,
StoreFunPtr const& o2)
{
return o1.asBase() == o2.asBase();
void * *fun1 = reinterpret_cast<void**> (o1.asBase());
void * *fun2 = reinterpret_cast<void**> (o2.asBase());
return *fun1 == *fun2;
}
};

View file

@ -98,6 +98,13 @@ namespace test {
check_Comparisons (Efp(testFunc), Efp(returnIt));
check_Comparisons (Evoid(testFunc), Evoid(returnIt));
ASSERT ( detect_Clone (Efun(testFunc)));
ASSERT (!detect_Clone (Efun(bindFunc))); //note equality not detected when cloning a bind term
ASSERT (!detect_Clone (Efun(pAplFunc))); //similarly
ASSERT (!detect_Clone (Efun(membFunc))); //analogous for bound member function
ASSERT ( detect_Clone (Efp(testFunc) ));
ASSERT ( detect_Clone (Evoid(testFunc)));
detect_unboundFunctor(Efun(testFunc), Efun(getterFunc), Efun(membFunc));
detect_unboundFunctor(Efp(testFunc),Efp(&testFunc), Efp(returnIt));
detect_unboundFunctor(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt));
@ -227,12 +234,17 @@ namespace test {
ASSERT (h1 == h1); ASSERT (!(h1 != h1));
ASSERT (h2 == h2); ASSERT (!(h2 != h2));
ASSERT (h1 != h2);
ASSERT (h1 != h2);
ASSERT (h2 != h1);
}
template<class HOL>
bool
detect_Clone (HOL const& h1)
{
HOL clone (h1);
ASSERT (clone == h1);
ASSERT (clone != h2);
return (clone == h1);
}