Boost logo

Boost Users :

Subject: Re: [Boost-users] How to cast a boost::shared_ptr to void*
From: michi7x7 (mailing-lists_at_[hidden])
Date: 2011-05-10 04:06:40


> 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).

smart_ptr<Class> ptr(new Class);
Class * raw_ptr = get_pointer(ptr);

You can cast the raw-pointer to void* of course.

-- 
Best regards,
michi7x7

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