Boost logo

Boost Users :

From: Bertolt Mildner (Bertolt.Mildner_at_[hidden])
Date: 2002-09-10 09:56:37


"Douglas Gregor" <gregod_at_[hidden]> schrieb im Newsbeitrag news:200209100949.40416.gregod_at_cs.rpi.edu...
> 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<boost::shared_ptr<Fct::Crypto::KeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, std::allocator<boost::function_base>>::function1<boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>>(boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>)')
  (instantiating: 'boost::function1<boost::shared_ptr<Fct::Crypto::KeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, std::allocator<boost::function_base>>::assign_to<boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>>(boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>)')
   (instantiating: 'boost::function1<boost::shared_ptr<Fct::Crypto::KeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, std::allocator<boost::function_base>>::assign_to<boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>>(boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>, boost::detail::function::function_obj_tag)')
    (instantiating: 'boost::detail::function::function_obj_invoker1<boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>, boost::shared_ptr<Fct::Crypto::KeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>::invoke(boost::detail::function::any_pointer, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>)')
function_template.hpp line 110             return (*f)(BOOST_FUNCTION_ARGS);
Error   : call of non-function
 (instantiating: 'boost::detail::function::function_obj_invoker1<boost::function2<boost::shared_ptr<Fct::Crypto::HostMemoryKeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>, boost::shared_ptr<Fct::Crypto::Engine>, std::allocator<boost::function_base>>, boost::shared_ptr<Fct::Crypto::KeyStorage<std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>>, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>>::invoke(boost::detail::function::any_pointer, std::vector<unsigned char, Fct::Base::SecureAllocator<unsigned char, Fct::Base::Private::WrappedBufferBaseAllocator>>)')
function_template.hpp line 110             return (*f)(BOOST_FUNCTION_ARGS);
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