Subject: [Boost-bugs] [Boost C++ Libraries] #2243: value_initialized should have its own swap functions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-08-21 19:32:56
#2243: value_initialized should have its own swap functions
------------------------------+---------------------------------------------
Reporter: niels_dekker | Owner: no-maintainer
Type: Feature Requests | Status: new
Milestone: Boost 1.37.0 | Component: utility
Version: Boost 1.36.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
For a given type {{{T}}}, the current (1.36.0) version of
{{{boost::value_initialized<T>}}} is ''only'' Swappable if it is both
!CopyConstructible and !CopyAssignable. IMO, {{{value_initialized<T>}}}
should be Swappable whenever {{{T}}} is Swappable. Moreover, when swapping
{{{value_initialized<T>}}} objects, the custom swap function of {{{T}}}
should be used, whenever available.
I'd like to propose resolving this issue by adding a swap member function
to {{{value_initialized<T>}}}, and a non-member swap that calls the
member. (As recommended by Scott Meyers, Effective C++ Third Edition, Item
25: ''Consider support for a non-throwing swap.'')
I would like to have {{{value_initialized<T>::swap}}} calling
{{{boost::swap}}} to swap its data, using the
[http://svn.boost.org/svn/boost/trunk/boost/utility/swap.hpp boost::swap
utility] by Joseph Gauterin ''et al'', that was recently added to the
trunk. The boost::swap utility internally uses ''argument-dependent
lookup'' (ADL) to find the custom swap function of {{{T}}}, if available.
Thereby it works around various compiler version specific bugs regarding
ADL, as tested at [http://www.boost.org/development/tests/trunk/developer
/utility-swap_.html utility-swap_.html]. Moreover, it supports swapping
arrays (as requested by ticket #2056), so {{{value_initialized<T>::swap}}}
would also support having {{{T}}} as a built-in array type.
Please take a look at the attached patch.
-- Ticket URL: <http://svn.boost.org/trac/boost/ticket/2243> 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:49:58 UTC