|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-11-22 07:14:07
Ion Gaztañaga wrote:
>>> 2. Add reinterpret_pointer_cast to complete cast family.
>>
>>
>> Out of curiosity, why do you want it?
>
> Well, currently I'm removing reinterpret_casts to convert void pointers
> with static_casts, but if there is some place where a reinterpret_cast
> has sense with raw pointers, I would add it to have complete family.
> But we can live with static_pointer_cast.
We actually do have a motivating example for reinterpret_pointer_cast:
function pointer casts, where you can't use void. Something like
shared_ptr<void()> get_function( char const * module, char const * name );
I think that it was Vladimir Prus that came up with this use case... Yes, it
was him:
http://lists.boost.org/Archives/boost/2004/08/70705.php
Thanks for reminding me. Another candidate for a TR1 extension proposal.
>> template<class T, class U, template<class> class Sp>
>> class pointer_to_other< Sp<T>, U >
>> {
>> typedef Sp<U> type;
>> };
>>
>> works with auto_ptr and all boost smart pointers. Other smart
>> pointers may want to specialize pointer_to_other.
>
> No problem at all. What about other overloads for 2 and 3 template
> parameter smart pointers, so that almost all smart pointers would be
> covered. Of course, we need another version for raw pointers. What
> about boost/utility/pointer_to_other.hpp?
No objections here, but what about documentation and tests? :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk