From: "Pavel Vasiliev" <[EMAIL PROTECTED]> [...] > Also there is a question related to boost::shared_ptr: what the > drawbacks would be in implementing it via void*? I mean > > template<class T> class shared_ptr > { > void * px; > detail::shared_count pn; > ... > public: > T * get() const > { > return static_cast<T*>(px); > } > } > > The advantage is that with void*-based implementation all > shared_ptr<>’s are layout-compatible and thus std containers may > be specialized for shared_ptr to reduce code bloat (since not all > linkers are as smart as MSVC++).
There are no significant drawbacks that I can see. The only drawback is that with a void * px it's easier to create a broken implementation that will almost work. For example template<class Y> shared_ptr<T>::shared_ptr(shared_ptr<Y> const & rhs): px(rhs.px), pn(rhs.pn) {} is buggy, and should now be template<class Y> shared_ptr<T>::shared_ptr(shared_ptr<Y> const & rhs): px(static_cast<T*>(rhs.get())), pn(rhs.pn) {} _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost