Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-02-25 11:30:35


Sam Partington wrote:
>
> I think I agree, we want to provide as little restrictions as possible.

Dave's argument is a good one. I agree, too.

> So, now with David's suggestion, I've attached what I propose.

That won't work as you made it a nested struct so it is still different
for all instantiations. I think Dave meant to go for this one:

// bool_testable contributed by Sam Partington
-----------------------------//

template <class T, class B>
struct bool_testable;

struct safe_bool
{
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
  template <class T, class B> friend class bool_testable;
#endif
  int x;
  typedef int safe_bool::*type;
};

template <class T, class B = ::boost::detail::empty_base>
struct bool_testable : B
{
  operator safe_bool::type() const
  {
    return !static_cast<const T&>(*this) ? 0 : &safe_bool::x;
  }
};

I also think it would be fair to mention Dave as a contributor, too, as
he provided the way to reduce the overhead.

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk