|
Boost Users : |
From: Bertolt Mildner (Bertolt.Mildner_at_[hidden])
Date: 2002-09-10 12:03:29
> shared_ptr reuses shared_ptr::get as the nonnull value, without a dummy
> nested class:
>
> // implicit conversion to "bool"
>
> typedef T * (this_type::*unspecified_bool_type)() const;
>
> operator unspecified_bool_type() const // never throws
> {
> return px == 0? 0: &this_type::get;
> }
>
> Perhaps something along these lines will work for boost::function.
Ok, here is my next try:
diff -r1.33 function_base.hpp
271c271
< function_base() : manager(0), functor(static_cast<void*>(0)) {}
--- > inline function_base() : manager(0), functor(static_cast<void*>(0)) {} 274c274 < bool empty() const { return !manager; } --- > inline bool empty() const { return !manager; } 284c284 < operator bool () const { return !this->empty(); } --- > inline operator bool () const { return !this->empty(); } 287,291c287 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); --- > typedef bool (function_base::*safe_bool)() const; 294,295c290,294 < operator safe_bool () const < { return (this->empty())? 0 : &dummy::nonnull; } --- > inline operator safe_bool () const > { return (this->empty())? 0 : &function_base::empty; } > > inline bool operator!() const > { return !this->empty(); } 297,298d295 < safe_bool operator!() const < { return (this->empty())? &dummy::nonnull : 0; } which again results in this error: Error : illegal use of precompiled header (included from: function.hpp:22 KeyStorage.h:12 HostMemoryKeyStorage.h:9 DesKey.h:10 MWPrefixWin32.pch++:15) function_base.hpp line 274 inline bool empty() const { return !manager; } Bertolt -- Free Crypto Token - FCT www.FreeCryptoToken.org
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net