Subject: [Boost-bugs] [Boost C++ Libraries] #13208: Make boost::optional<T> trivially destructible, copyable and movable if T is
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-13 09:59:39
#13208: Make boost::optional<T> trivially destructible, copyable and movable if T
is
------------------------------+-------------------------------
Reporter: 1zeeky@⦠| Owner: Fernando Cacciola
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: optional
Version: | Severity: Not Applicable
Keywords: |
------------------------------+-------------------------------
Conceptually there's nothing preventing {{{boost::optional<T>}}} from
being trivially destructible, copyable and movable if T is.
This could be useful, for instance, to use an {{{boost::optional<T>}}} as
a union-member.
I have a POC implementation based on Boost 1.64
[https://github.com/z33ky/trivial_optional/blob/master/optional.hpp here].
\\
I moved {{{m_storage}}} and {{{m_initialized}}} to a new {{{class
optional_storage}}}, representing the new base class. Some methods
managing those members are move there as well.
{{{optional_base}}} indirectly inherits from {{{optional_storage}}}
through {{{optional_destroyer}}}, {{{optional_mover}}} and
{{{optional_copier}}}, which are templated classes including a boolean
parameter to determine whether {{{T}}} is trivially destructible, movable
and copyable and use template specialization to provide the respective
trivial members. \\
The implementation relies on defaulting constructors, so without C++11 or
newer only trivial destruction is possible.
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13208> 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-09-13 10:06:08 UTC