Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2008-01-16 04:35:14


Author: niels_dekker
Date: 2008-01-16 04:35:12 EST (Wed, 16 Jan 2008)
New Revision: 42815
URL: http://svn.boost.org/trac/boost/changeset/42815

Log:
Added convenience class initialized_value, as announced at http://article.gmane.org/gmane.comp.lib.boost.devel/169833
Text files modified:
   trunk/boost/utility/value_init.hpp | 35 ++++++++++++++++++-----------------
   1 files changed, 18 insertions(+), 17 deletions(-)

Modified: trunk/boost/utility/value_init.hpp
==============================================================================
--- trunk/boost/utility/value_init.hpp (original)
+++ trunk/boost/utility/value_init.hpp 2008-01-16 04:35:12 EST (Wed, 16 Jan 2008)
@@ -1,31 +1,20 @@
-// (C) Copyright 2002-2007, Fernando Luis Cacciola Carballal.
+// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 // 21 Ago 2002 (Created) Fernando Cacciola
-// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker
+// 16 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
 
 // Note: The implementation of boost::value_initialized had to deal with the
-// fact that various compilers haven't fully implemented value-initialization:
-// Microsoft Feedback ID 100744 - Value-initialization in new-expression
-// Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28
-// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
-// GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members
-// Reported by Jonathan Wakely, 2006-12-07
-// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
-// GCC Bug 33916 - Default constructor fails to initialize array members
-// Reported by Michael Elizabeth Chastain, 2007-10-26
-// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
-// Borland Report 51854 - Value-initialization: POD struct should be zero-initialized
-// Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09
-// http://qc.codegear.com/wc/qcmain.aspx?d=51854
-// The constructor of boost::value_initialized<T> works around these issues, by
-// clearing the bytes of T, before constructing the T object it contains.
+// fact that various compilers haven't fully implemented value-initialization.
+// The constructor of boost::value_initialized<T> works around these compiler
+// issues, by clearing the bytes of T, before constructing the T object it
+// contains. More details on these issues are at libs/utility/value_init.htm
 
 #include <boost/aligned_storage.hpp>
 #include <boost/detail/workaround.hpp>
@@ -110,6 +99,18 @@
   return x.data() ;
 }
 
+
+class initialized_value
+{
+ public :
+
+ template <class T> operator T() const
+ {
+ return get( value_initialized<T>() );
+ }
+};
+
+
 } // namespace boost
 
 


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