From fea85acd0e85f47e1c6793f9915233afd441ad45 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 5 Oct 2009 01:38:35 +0200 Subject: [PATCH] equality comparisons on function erasure objects covered ...well, as good as possible, as boost refuses to implement this feature --- src/lib/meta/function-erasure.hpp | 4 +++- tests/lib/meta/function-erasure-test.cpp | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/lib/meta/function-erasure.hpp b/src/lib/meta/function-erasure.hpp index 292260e7c..0590117bc 100644 --- a/src/lib/meta/function-erasure.hpp +++ b/src/lib/meta/function-erasure.hpp @@ -184,7 +184,9 @@ namespace typelist{ operator== (StoreFunPtr const& o1, StoreFunPtr const& o2) { - return o1.asBase() == o2.asBase(); + void * *fun1 = reinterpret_cast (o1.asBase()); + void * *fun2 = reinterpret_cast (o2.asBase()); + return *fun1 == *fun2; } }; diff --git a/tests/lib/meta/function-erasure-test.cpp b/tests/lib/meta/function-erasure-test.cpp index 27bddaee8..090fb8825 100644 --- a/tests/lib/meta/function-erasure-test.cpp +++ b/tests/lib/meta/function-erasure-test.cpp @@ -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 + bool + detect_Clone (HOL const& h1) + { HOL clone (h1); - ASSERT (clone == h1); - ASSERT (clone != h2); + return (clone == h1); }