Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2008-01-30 17:42:23


Author: niels_dekker
Date: 2008-01-30 17:42:23 EST (Wed, 30 Jan 2008)
New Revision: 43025
URL: http://svn.boost.org/trac/boost/changeset/43025

Log:
value_init: Removed aligned_storage::address() calls, to improve TR1 compatibility, as confirmed by John Maddock. Added internal helper function, wrapper_address(), as discussed with Fernando.
Text files modified:
   trunk/boost/utility/value_init.hpp | 26 +++++++++++++++++---------
   1 files changed, 17 insertions(+), 9 deletions(-)

Modified: trunk/boost/utility/value_init.hpp
==============================================================================
--- trunk/boost/utility/value_init.hpp (original)
+++ trunk/boost/utility/value_init.hpp 2008-01-30 17:42:23 EST (Wed, 30 Jan 2008)
@@ -5,7 +5,7 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 // 21 Ago 2002 (Created) Fernando Cacciola
-// 19 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
+// 30 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
 //
 #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
 #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
@@ -37,13 +37,22 @@
       remove_const<T>::type data;
     };
 
- mutable aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value> x;
+ mutable
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
+ typename
+#endif
+ aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
+
+ wrapper * wrapper_address() const
+ {
+ return static_cast<wrapper *>( static_cast<void*>(&x));
+ }
 
   public :
 
     value_initialized()
     {
- std::memset(x.address(), 0, sizeof(x));
+ std::memset(&x, 0, sizeof(x));
 #ifdef BOOST_MSVC
 #pragma warning(push)
 #if _MSC_VER >= 1310
@@ -53,7 +62,7 @@
 #pragma warning(disable: 4345)
 #endif
 #endif
- new (x.address()) wrapper();
+ new (wrapper_address()) wrapper();
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
@@ -61,24 +70,23 @@
 
     value_initialized(value_initialized const & arg)
     {
- new (x.address()) wrapper( *static_cast<wrapper const *>(arg.x.address()) );
+ new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
     }
 
     value_initialized & operator=(value_initialized const & arg)
     {
- T const & arg_data = arg.data();
- this->data() = arg_data;
+ this->data() = static_cast<T const &>( arg.data() );
       return *this;
     }
 
     ~value_initialized()
     {
- static_cast<wrapper *>(x.address())->wrapper::~wrapper();
+ wrapper_address()->wrapper::~wrapper();
     }
 
     T& data() const
     {
- return static_cast<wrapper *>(x.address())->data;
+ return wrapper_address()->data;
     }
 
     operator T&() const { return this->data(); }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk