move the member pointer to the current stack frame...

hopefully the optimiser will remove it completely ;-)
This commit is contained in:
Fischlurch 2009-06-26 17:13:36 +02:00
parent a30461780b
commit 5291f6e41a
2 changed files with 14 additions and 11 deletions

View file

@ -99,19 +99,18 @@ namespace typelist{
{
typedef bool (T::*ValidityCheck)() const;
typedef ValidityCheck _unspecified_bool_type;
ValidityCheck isValid;
BoolCheckable() : isValid (&T::isValid) {}
/** implicit conversion to "bool" */
operator _unspecified_bool_type() const ///< never throws
{
ValidityCheck isValid (&T::isValid);
T const& obj = static_cast<T const&> (*this);
return (obj.*isValid)()? isValid : 0;
}
bool operator! () const ///< never throws
{
ValidityCheck isValid (&T::isValid);
T const& obj = static_cast<T const&> (*this);
return !(obj.*isValid)();
}

View file

@ -49,7 +49,7 @@ using boost::format;
bool
isValid() const
{
return true;
return val_ % 2;
}
};
@ -61,16 +61,20 @@ main (int, char**) //(int argc, char* argv[])
{
NOBUG_INIT;
TestIt1 testrosteron (22);
bool boo = testrosteron;
for (int i=0; i<10; ++i)
{
TestIt1 testrosteron (i);
if (testrosteron)
cout << "doIt \n";
if (!testrosteron)
cout << i << "\n";
}
cout << "size=" << sizeof(TestIt1) <<"\n";
cout << "\n.gulp.\n";
if (boo)
cout << "size=" << sizeof(TestIt1) <<"\n";
return 0;
}