try to fix a failing test (not really fixed yet)

This commit is contained in:
Fischlurch 2009-07-04 00:22:16 +02:00
parent d13d461a9c
commit b65658c10d
2 changed files with 15 additions and 8 deletions

View file

@ -64,6 +64,7 @@ namespace lumiera {
namespace typelist{
using std::tr1::function;
using util::unConst;
@ -100,8 +101,6 @@ namespace typelist{
* Using this policy allows to store arbitrary complex functor objects
* embedded within a neutral container and retrieving them later type-safe.
* The price to pay is vtable access and heap storage of function arguments.
*
* @note the bool conversion and #isValid are highly implementation dependent
*/
class StoreFunction
: public lib::BoolCheckable<StoreFunction>
@ -112,6 +111,7 @@ namespace typelist{
enum { SIZE = sizeof(function<void(void)>) };
char storage_[SIZE];
virtual ~Holder() {}
virtual bool isValid() const { return false; }
};
/** embedding the concrete functor object */
@ -129,6 +129,12 @@ namespace typelist{
{
get().~Functor();
}
bool
isValid() const
{
const Functor& func (unConst(this)->get());
return bool(func);
}
Functor&
get()
{
@ -161,9 +167,9 @@ namespace typelist{
}
bool
isValid() const ///< @note implementation dependent!!
isValid() const
{
return reinterpret_cast<void*> (holder_.storage_[0]);
return holder_.isValid();
}
};

View file

@ -47,9 +47,9 @@ namespace test {
typedef FunErasure<StoreUncheckedFunPtr> Evoid;
template<class HOL>
struct BuildEmptyHolder { typedef long (*Type)(int,char); };
struct BuildEmptyFunctor { typedef long (*Type)(int,char); };
template<>
struct BuildEmptyHolder<Efun> { typedef function<long(int,char)> Type; };
struct BuildEmptyFunctor<Efun> { typedef function<long(int,char)> Type; };
/***********************************************************************
@ -210,8 +210,9 @@ namespace test {
{
// fabricate an unbound functor...
typedef typename BuildEmptyHolder<HOL>::Type EmptyHolder;
EmptyHolder emptyHolder;
typedef typename BuildEmptyFunctor<HOL>::Type NoFunc;
NoFunc noFunction;
HOL emptyHolder (noFunction);
ASSERT (!emptyHolder);
ASSERT ( h1 );
ASSERT ( h2 );