|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69941 - trunk/boost
From: eric_at_[hidden]
Date: 2011-03-13 10:41:55
Author: eric_niebler
Date: 2011-03-13 10:41:51 EDT (Sun, 13 Mar 2011)
New Revision: 69941
URL: http://svn.boost.org/trac/boost/changeset/69941
Log:
use rvalue refs on supporting compilers for const rvalue detection
Text files modified:
trunk/boost/foreach.hpp | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
Modified: trunk/boost/foreach.hpp
==============================================================================
--- trunk/boost/foreach.hpp (original)
+++ trunk/boost/foreach.hpp 2011-03-13 10:41:51 EDT (Sun, 13 Mar 2011)
@@ -15,6 +15,7 @@
// Alisdair Meredith - For help porting to Borland
// Stefan Slapeta - For help porting to Intel
// David Jenkins - For help finding a Microsoft Code Analysis bug
+// mimomorin_at_... - For a patch to use rvalue refs on supporting compilers
#ifndef BOOST_FOREACH
@@ -30,8 +31,10 @@
#include <boost/detail/workaround.hpp>
// Some compilers let us detect even const-qualified rvalues at compile-time
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1310) && !defined(_PREFAST_) \
- || (BOOST_WORKAROUND(__GNUC__, >= 4) && !defined(BOOST_INTEL) && !defined(BOOST_CLANG)) \
+#if !defined(BOOST_NO_RVALUE_REFERENCES) \
+ || BOOST_WORKAROUND(BOOST_MSVC, >= 1310) && !defined(_PREFAST_) \
+ || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) && \
+ !defined(BOOST_CLANG)) \
|| (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ >= 4) && !defined(BOOST_INTEL) && \
!defined(BOOST_CLANG))
# define BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION
@@ -80,6 +83,7 @@
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_abstract.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
+#include <boost/type_traits/is_rvalue_reference.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/foreach_fwd.hpp>
@@ -214,12 +218,6 @@
inline boost::mpl::not_<Bool1> *not_(Bool1 *) { return 0; }
template<typename T>
-inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; }
-
-template<typename T>
-inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; }
-
-template<typename T>
inline boost::is_array<T> *is_array_(T const &) { return 0; }
template<typename T>
@@ -230,6 +228,17 @@
inline boost::mpl::true_ *is_const_(T const &) { return 0; }
#endif
+#ifdef BOOST_NO_RVALUE_REFERENCES
+template<typename T>
+inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; }
+
+template<typename T>
+inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; }
+#else
+template<typename T>
+inline boost::is_rvalue_reference<T &&> *is_rvalue_(T &&, int) { return 0; }
+#endif
+
///////////////////////////////////////////////////////////////////////////////
// auto_any_t/auto_any
// General utility for putting an object of any type into automatic storage
@@ -445,7 +454,18 @@
);
}
-#ifdef BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION
+#if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \
+ && !defined(BOOST_NO_RVALUE_REFERENCES)
+///////////////////////////////////////////////////////////////////////////////
+// Rvalue references makes it drop-dead simple to detect at compile time
+// whether an expression is an rvalue.
+///////////////////////////////////////////////////////////////////////////////
+
+# define BOOST_FOREACH_IS_RVALUE(COL) \
+ boost::foreach_detail_::is_rvalue_((COL), 0)
+
+#elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \
+ && defined(BOOST_NO_RVALUE_REFERENCES)
///////////////////////////////////////////////////////////////////////////////
// Detect at compile-time whether an expression yields an rvalue or
// an lvalue. This is rather non-standard, but some popular compilers
@@ -902,7 +922,7 @@
boost::foreach_detail_::to_ptr(COL) \
, boost_foreach_argument_dependent_lookup_hack_value))
-#ifdef BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION
+#if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)
///////////////////////////////////////////////////////////////////////////////
// R-values and const R-values supported here with zero runtime overhead
///////////////////////////////////////////////////////////////////////////////
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