[Boost-bugs] [Boost C++ Libraries] #11032: boost::offset_ptr needs explicit ctor

Subject: [Boost-bugs] [Boost C++ Libraries] #11032: boost::offset_ptr needs explicit ctor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-02-16 14:38:13


#11032: boost::offset_ptr needs explicit ctor
------------------------------+--------------------------
 Reporter: stheophil@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+--------------------------
 Both the libc++ std library implementation and the MSVC library
 implementation require that their pointer types can be upcast.

 The list and tree data structures have a class hierarchy of node types and
 often seem to pass pointers to the base types (or to offset_ptr<void>)
 that are then upcast to the most derived types. offset_ptr has no explicit
 constructor that allows upcasts, only implicit ctors for downcasts.

 We have patched our version of offset_ptr with this constructor:

 {{{
 //!Explicit constructor from other offset_ptr. Never throws.
 template<class T2>
 explicit offset_ptr(const offset_ptr<T2, DifferenceType, OffsetType,
 OffsetAlignment> &ptr
    , typename ipcdetail::enable_if_c<
    !ipcdetail::is_convertible<T2*, PointedType*>::value
>::type * = 0)
     :
 internal(ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(ptr.get()),
 this))
  {}

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11032>
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