|
Boost Users : |
Subject: Re: [Boost-users] How to cast a boost::shared_ptr to void*
From: spam-receiver_at_[hidden]
Date: 2011-05-10 04:33:04
-------- Original Message --------
Subject: Re: [Boost-users] How to cast a boost::shared_ptr to void*
From: michi7x7 <mailing-lists_at_[hidden]>
To: boost-users_at_[hidden]
Date: Tue May 10 2011 10:06:40 GMT+0200
>> Hi all,
> Hi
>
>> My requirement is to cast an object of type shared_ptr as void*, so that
>> I can send it to a callback function that accepts a void*. I cannot
>> change callback the function signature because it is part of an existing
>> legacy code.
>>
>
> You can get the raw-pointer using the member-function get() or the free
> function get_pointer (which should be prefered).
Why should the free function be preferred?
>
> smart_ptr<Class> ptr(new Class);
> Class * raw_ptr = get_pointer(ptr);
>
> You can cast the raw-pointer to void* of course.
>
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