mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-01 05:34:36 +02:00
Remove dynamic_cast in init_internal_shared_once()
[SVN r44744]
This commit is contained in:
@@ -23,14 +23,11 @@ namespace boost
|
|||||||
|
|
||||||
template<class T> class enable_shared_from_this
|
template<class T> class enable_shared_from_this
|
||||||
{
|
{
|
||||||
// dynamic cast to template type doesn't work in constructor, so we have
|
|
||||||
// to use lazy initialization
|
|
||||||
void init_internal_shared_once() const
|
void init_internal_shared_once() const
|
||||||
{
|
{
|
||||||
if( !owned() && _internal_shared_count.empty() )
|
if( !owned() && _internal_shared_count.empty() )
|
||||||
{
|
{
|
||||||
T * p = dynamic_cast<T *>(const_cast<enable_shared_from_this*>(this));
|
detail::shared_count( (void*)0, detail::sp_deleter_wrapper() ).swap(_internal_shared_count);
|
||||||
detail::shared_count( p, detail::sp_deleter_wrapper() ).swap(_internal_shared_count);
|
|
||||||
_internal_weak_count = _internal_shared_count;
|
_internal_weak_count = _internal_shared_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user