forked from boostorg/smart_ptr
Removed casts as unsafe.
[SVN r13179]
This commit is contained in:
@@ -51,29 +51,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
weak_ptr(weak_ptr<Y> const & r, detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
weak_ptr(weak_ptr<Y> const & r, detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
|
||||
{
|
||||
if (px == 0) // need to allocate new counter -- the cast failed
|
||||
{
|
||||
pn = detail::weak_count();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
weak_ptr(weak_ptr<Y> const & r, detail::polymorphic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
|
||||
{
|
||||
if (px == 0)
|
||||
{
|
||||
throw std::bad_cast();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
weak_ptr & operator=(weak_ptr<Y> const & r) // never throws
|
||||
{
|
||||
@@ -187,27 +164,6 @@ template<class T> shared_ptr<T> make_shared(weak_ptr<T> const & r) // never thro
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> weak_ptr<T> shared_static_cast(weak_ptr<U> const & r)
|
||||
{
|
||||
return weak_ptr<T>(r, detail::static_cast_tag());
|
||||
}
|
||||
|
||||
template<class T, class U> weak_ptr<T> shared_dynamic_cast(weak_ptr<U> const & r)
|
||||
{
|
||||
return weak_ptr<T>(r, detail::dynamic_cast_tag());
|
||||
}
|
||||
|
||||
template<typename T, typename U> weak_ptr<T> shared_polymorphic_cast(weak_ptr<U> const & r)
|
||||
{
|
||||
return weak_ptr<T>(r, detail::polymorphic_cast_tag());
|
||||
}
|
||||
|
||||
template<typename T, typename U> weak_ptr<T> shared_polymorphic_downcast(weak_ptr<U> const & r)
|
||||
{
|
||||
BOOST_ASSERT(dynamic_cast<T *>(r.get()) == r.get());
|
||||
return shared_static_cast<T>(r);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
|
||||
Reference in New Issue
Block a user