Boost logo

Boost Users :

From: Lars Hagström (lars_at_[hidden])
Date: 2007-10-31 05:41:45


Yes, but it has to be safer and more correct to use static_pointer_casts
instead of reinterpret_cast.
In my particular situation I am unfortunately not able to use templates,
so I do need to do "ugly" pointer stuff.
(I am porting an existing shared-memory solution to boost::interprocess).

I've uncommented the static_pointer_cast et al functions from
offset_ptr.hpp, and they appear to do their work beautifully.

Lars

Michael Linck wrote:
> You can theoretically use reinterpret_cast to do that. However, you
> should be warned that void * hacks are extremely dangerous, and in poor
> taste. You should be better off, and much much safer, using templates
> instead.
>
> The static pointer cast may be commented out for that very reason :)
>
> mike
>
>
>> In offset_ptr.hpp the static_pointer_cast<> &co are commented out. Why
>> is this?
>> I need something of the kind to do casts from a void* to a bool*, for
>> example.
>>
>> Is there something I am missing?
>>
>> Lars
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users




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