"Douglas Gregor"
On Tuesday 10 September 2002 08:29 am, Bertolt Mildner wrote:
[...]
I have tried to make nonnull() inline and/or static but that didn't help. I think the root of the problem is that the address of nonnull() is taken. I wonder if it is really needed to return a real (member) function pointer or if it would be OK to just return (safe_bool)1 ?
Don't know if this is useful but at least it makes my compiler more happy [snip]
{ return (this->empty())? 0 : (safe_bool)~0; } { return (this->empty())? (safe_bool)~0 : 0; }
Unfortunately, that invokes implementation-defined behavior, because (safe_bool)~0 may or may not be the null pointer. [...]
Is really only a valid (member) function pointer guaranteed to be non-null? I think it is very strange that ~0 may not be non-null! I have tried this one: diff -r1.33 function_base.hpp 267a268,275
namespace detail { inline void nonnull() { } }
274c282 < bool empty() const { return !manager; } ---
inline bool empty() const { return !manager; }
284c292 < operator bool () const { return !this->empty(); } ---
inline operator bool () const { return !this->empty(); }
287,291c295 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); ---
typedef void (*safe_bool)();
294,295c298,299 < operator safe_bool () const < { return (this->empty())? 0 : &dummy::nonnull; } ---
inline operator safe_bool () const { return (this->empty())? 0 : &detail::nonnull; }
297,298c301,302 < safe_bool operator!() const < { return (this->empty())? &dummy::nonnull : 0; } ---
inline safe_bool operator!() const { return (this->empty())? &detail::nonnull : 0; }
*but*, now I get the following errors:
Error : call of non-function
(instantiating: 'boost::function1