|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-07-04 12:40:51
Scott French wrote:
> Hello,
>
> Should the following code sample work? It is the simplest reproduction
> case I could come up with:
>
> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/bind.hpp>
> #include <boost/shared_ptr.hpp>
> #include <stdlib.h>
>
> using namespace std;
> using namespace boost;
> using namespace boost::lambda;
>
> int main(void)
> {
> void * myResource = malloc(5);
> shared_ptr<void> mySharedResource(myResource, bind(free, _1));
> }
>
> I get a compile error using g++ 4.0.1 on Mac OS X:
...
My personal opinion is that overloading unary & is evil. My professional
opinion is that the code should work. :-) Please apply the following patch
(already in CVS):
diff -u -r1.4 sp_counted_impl.hpp
--- boost/detail/sp_counted_impl.hpp 11 Nov 2005 21:06:08 -0000 1.4
+++ boost/detail/sp_counted_impl.hpp 4 Jul 2007 16:34:16 -0000
@@ -147,7 +147,7 @@
virtual void * get_deleter( std::type_info const & ti )
{
- return ti == typeid(D)? &del: 0;
+ return ti == typeid(D)? &reinterpret_cast<char&>( del ): 0;
}
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
@@ -217,7 +217,7 @@
virtual void * get_deleter( std::type_info const & ti )
{
- return ti == typeid( D )? &d_: 0;
+ return ti == typeid( D )? &reinterpret_cast<char&>( d_ ): 0;
}
};
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