Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2003-11-28 10:57:52


On Fri, 28 Nov 2003, David Abrahams wrote:
> Douglas Paul Gregor <gregod_at_[hidden]> writes:
>
> > On Thu, 27 Nov 2003, Sam Partington wrote:
> >> template <class T, class B = ::boost::detail::empty_base>
> >> struct safe_bool : B
> >> {
> >> typedef bool (T::*safe_bool_type)() const;
> >>
> >> operator safe_bool_type() const { return !static_cast<const
> >> T&>(*this) ? 0 : &T::operator!; }
> >> private:
> >> bool operator!=(const safe_bool<T>& rhs) const;
> >> bool operator==(const safe_bool<T>& rhs) const;
> >> };
> >
> > I'd be fine with this, but we should be using a member data pointer
> > instead of a member function pointer.
>
> Yes, but you can't do it without requiring the derived class to *have*
> an accessible data member.

  struct some_safe_bool_nested_class {
    int my_data_member;
  };

  typedef int some_safe_bool_nested_class::*safe_bool_type;

?

You don't ever need an instance of some_safe_bool_nested_class.

        Doug


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