Modify

Opened 4 months ago

Last modified 3 months ago

#13165 new Feature Requests

inplace_ptr

Reported by: gast128@… Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.64.0 Severity: Not Applicable
Keywords: Cc:

Description

Boost.Optional uses in place object creation. In many cases it could used as a drop in repelacment of scoped_ptr with the benefit of circumventing a memory allocation and locality of memory access.

However its semantics is 'optional' and not like a fast replacement of scoped_ptr. Wouldn't it be an idea to add something like this to the smart_ptr library? Names can be e.g. inplace_ptr, value_ptr, etc. We could also use Boost.Optional but colleagues might get confused, since you do not use the 'optional' aspect but its performance aspect.

Note that people might wonder why not use value based directly, but there are still some use cases:

  • for pimpl idiom / hide expansive headers (e.g. multi index) in client
  • 2 phase construction, where information is not yet available at parent constructor time.

Only drawback is that you lose polymorphism.

https://stackoverflow.com/questions/22636407/why-not-use-boostoptional-as-a-better-scoped-ptr

Attachments (0)

Change History (1)

comment:1 Changed 3 months ago by gast128 <gast128@…>

...the pimpl idiom can't be solved with this; it needs the definition anyway.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Peter Dimov.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.