Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-02-25 09:12:29


Daniel Frey wrote:
>
> The only problem I see is that an instance of safe_bool_conversion is
> created which is not really needed. I suggest to rely on the operator!
> provided by T:
>
> template< class T, class B = ::boost::detail::empty_base >
> struct bool_testable : B
> {
> private:
> typedef bool (T::*unspecified_bool_type)() const;
>
> public:
> operator unspecified_bool_type() const
> {
> return !static_cast< const T& >( *this ) ? 0 : &T::operator!();

Should be ...operator!; without the braces, sorry.

> }
> };

It has another advantage: It makes the compiler complain if the user
didn't provided an operator! with the right signature. This is - in this
case and IMHO - a good thing.

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