|
Boost Users : |
From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2007-03-21 13:57:36
"Michael Marcin" <mike_at_[hidden]> wrote in message
news:etqr7a$ocr$1_at_sea.gmane.org...
> Gennadiy Rozental wrote:
>> "Michael Marcin" <mike_at_[hidden]> wrote in message
>> news:etqf0t$6ea$1_at_sea.gmane.org...
>>> Unless I'm missing something it looks like polymorphic_downcast doesn't
>>> provide an overload for reference types... is there a reason? This
>>> makes it a little inconvenient for use.
>>
>> I brought this up some time ago. No one seemed to care enough to work on
>> docs update. As usual in many volunteering based projects ;)
>>
>> R u up to it?
>>
>
> Is the problem the docs or the lack of an overload supporting
> references?
Primarily docs. Search the development mailing list archive.
> Shouldn't something like this work?
>
> #include <boost/type_traits/remove_reference.hpp>
> #include <boost/type_traits/add_pointer.hpp>
> #include <boost/utility/addressof.hpp>
>
> namespace boost
> {
> template <class Target, class Source>
> inline Target polymorphic_downcast( Source& x )
> {
> BOOST_ASSERT( dynamic_cast< typename add_pointer< typename
> remove_reference<Target>::type >::type >( addressof(x) ) == addressof(x)
> ); // detect logic error
> return static_cast<Target>(x);
> }
> } //end namespace boost
I believe my version did something along these lines.
Genandiy
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