Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10798: boost::movelib::unique_ptr resolves typedef pointer with the deletor's
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-11-25 08:52:27
#10798: boost::movelib::unique_ptr resolves typedef pointer with the deletor's
-------------------------------------------------+-------------------------
Reporter: Matteo Settenvini | Owner: igaztanaga
<matteo.settenvini@â¦> | Status: new
Type: Bugs | Component: move
Milestone: To Be Determined | Severity: Problem
Version: Boost 1.57.0 | Keywords:
Resolution: |
-------------------------------------------------+-------------------------
Comment (by Matteo Settenvini <matteo.settenvini@â¦>):
Unfortunately not, since the deleter I wrote uses a field of the base
class to determine the runtime type of the object, and resolves a call to
the right destructor (plus, deallocates memory with the right custom
allocator). This is needed since we have no virtuality in objects of
classes that need to be stored in shared memory.
In other words, I need to use just a deleter for the whole hierarchy of
classes, and thus its pointer member needs to be the base type. We're
rolling out our handmade version of virtuality, with virtual tables and
all that goes with them.
What I find counter-intuitive from a design standpoint, is that:
* be it that we have classes Derived < Base.
* given a Deleter with a member "pointer" as a typedef to Base.
* defining a unique_ptr<Derived, Deleter> and invoking ::get() results
in a pointer to Base being returned.
What is the technical reason of having the pointer typedef of the
unique_ptr using the pointer member of the deleter, instead than rebinding
it to allow upcasts?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10798#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC