Boost logo

Boost :

Subject: Re: [boost] [utility] rvalue support in value_initialized
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-09-19 07:41:31


On 19/09/2011 05:14, Joel de Guzman wrote:

> Where is it? Was it submitted?

I sent it to several people by email a long time ago, you included.
I don't think it was ever applied.
Christopher Schmidt said he was fixing problems by the end of the week
but I never got news of him.

Anyway, the bit for value_initialized is the following:

Index: boost/utility/value_init.hpp
===================================================================
--- boost/utility/value_init.hpp (révision 69204)
+++ boost/utility/value_init.hpp (copie de travail)
@@ -22,7 +22,7 @@
  // contains. More details on these issues are at
libs/utility/value_init.htm

  #include <boost/aligned_storage.hpp>
-#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
+#include <boost/config.hpp> // For
BOOST_NO_COMPLETE_VALUE_INITIALIZATION and BOOST_NO_RVALUE_REFERENCES.
  #include <boost/detail/workaround.hpp>
  #include <boost/static_assert.hpp>
  #include <boost/type_traits/cv_traits.hpp>
@@ -30,6 +30,9 @@
  #include <boost/swap.hpp>
  #include <cstring>
  #include <new>
+#ifndef BOOST_NO_RVALUE_REFERENCES
+#include <utility>
+#endif

  #ifdef BOOST_MSVC
  #pragma warning(push)
@@ -169,7 +172,23 @@
    return x.data() ;
  }

+#ifndef BOOST_NO_RVALUE_REFERENCES
+
  template<class T>
+T&& get ( initialized<T>&& x )
+{
+ return std::move(x.data()) ;
+}
+
+template<class T>
+T const&& get ( const initialized<T>&& x )
+{
+ return std::move(x.data()) ;
+}
+
+#endif
+
+template<class T>
  void swap ( initialized<T> & lhs, initialized<T> & rhs )
  {
    lhs.swap(rhs) ;
@@ -229,7 +248,23 @@
    return x.data() ;
  }

+#ifndef BOOST_NO_RVALUE_REFERENCES
+
  template<class T>
+T&& get ( value_initialized<T>&& x )
+{
+ return std::move(x.data()) ;
+}
+
+template<class T>
+T const&& get ( const value_initialized<T>&& x )
+{
+ return std::move(x.data()) ;
+}
+
+#endif
+
+template<class T>
  void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
  {
    lhs.swap(rhs) ;

Note however that it assumes that if BOOST_NO_RVALUE_REFERENCES is not
set, then you have std::move in <utility>, which isn't the case with
certain compilers.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk