Added value_initialized::swap according to ticket #2243, as agreed with Fernando Cacciola :-)

[SVN r48424]
This commit is contained in:
Niels Dekker 2008-08-28 18:37:45 +00:00
parent d264005c11
commit 55f303baec

View File

@ -7,6 +7,7 @@
// 21 Ago 2002 (Created) Fernando Cacciola
// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker
// 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola
// 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola
//
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
@ -22,6 +23,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/swap.hpp>
#include <cstring>
#include <new>
@ -93,6 +95,11 @@ class value_initialized
return wrapper_address()->data;
}
void swap(value_initialized & arg)
{
::boost::swap( this->data(), arg.data() );
}
operator T&() const { return this->data(); }
} ;
@ -110,6 +117,12 @@ T& get ( value_initialized<T>& x )
return x.data() ;
}
template<class T>
void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
{
lhs.swap(rhs) ;
}
class initialized_value_t
{