$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: mr_lilirong_at_[hidden]
Date: 2001-11-21 23:21:48
Hi,
The following code is excerpted from Boost.Function. I just don't
unstanding it. Why use "safe_bool"? What's the advantage? Can any one
explain it to me?
Thanks.
// code from <boost/function/function_base.hpp>
// ===>
private:
struct dummy {
void nonnull() {};
};
typedef void (dummy::*safe_bool)();
public:
operator safe_bool () const
{ return (this->empty())? 0 : &dummy::nonnull; }
safe_bool operator!() const
{ return (this->empty())? &dummy::nonnull : 0; }
// code from <boost/function/function_base.hpp>
// <===