move the member pointer to the current stack frame...
hopefully the optimiser will remove it completely ;-)
This commit is contained in:
parent
a30461780b
commit
5291f6e41a
2 changed files with 14 additions and 11 deletions
|
|
@ -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)();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue