> Essentially you supply a operator! and it supplies an unspecified-bool-type
> conversion operator.
Nice idea! I already had something similar in mind, but you managed to
make it really generic.
> //Key
> //T: primary operand type
> //t: values of type T
>
> // Template Supplied Operations Requirements
> //
> // bool_testable<T> operator unspecified-bool-type() !t
>
> template <class T, class B = ::boost::detail::empty_base> struct
> bool_testable : B
> {
> private:
> void safe_bool_conversion() const { }
> public:
>
> typedef void (bool_testable<T, B>::*unspecified_bool_type)() const;
> operator unspecified_bool_type() const
> {
> return !static_cast<const T&>(*this) ? 0 : &bool_testable<T,
> B>::safe_bool_conversion;
> }
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!();
}
};
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: [EMAIL PROTECTED], web: http://www.aixigo.de
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost