Boost logo

Boost Users :

From: Bertolt Mildner (Bertolt.Mildner_at_[hidden])
Date: 2002-09-12 03:37:08


> > [...]
> > >> CW now gives me the same error in operator safe_bool() ...<<<
> > >
> > > I'm curious... Do you get an error when you put boost/shared_ptr.hpp in
> a
> > > precompiled header?
> >
> > No, I had no problems with Boost in precompiled headers so far except with
> Boost.Function.
> >
> > I'm using shared_ptr, BOOST_STATIC_ASSERT, lexical_cast, Boost.Threads,
> pool allocator, iterator adapters, any, ...<
>
> 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, I think the problem is that function_base is not a template.

This should fix it:

diff -r1.33 function_base.hpp
268c268,269
< class function_base

---
>   template <typename do_not_use = int>
>   class function_base_impl
271c272
<     function_base() : manager(0), functor(static_cast<void*>(0)) {}
---
>     function_base_impl() : manager(0), functor(static_cast<void*>(0)) {}
287,291c288
<     struct dummy {
<       void nonnull() {};
<     };
< 
<     typedef void (dummy::*safe_bool)();
---
>     typedef bool (function_base_impl<>::*safe_bool)() const;
295c292
<       { return (this->empty())? 0 : &dummy::nonnull; }
---
>       { return (this->empty())? 0 : &function_base_impl<>::empty; }
297,298c294,295
<     safe_bool operator!() const
<       { return (this->empty())? &dummy::nonnull : 0; }
---
>     bool operator!() const
>       { return this->empty(); }
300a298,299
> 
>   typedef function_base_impl<> function_base;
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