Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-28 09:12:36


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.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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