Ticket #5279: foreach.2.patch

File foreach.2.patch, 2.0 KB (added by mimomorin@…, 12 years ago)

A patch against trunk. Disables compile-time const rvalue detection in gcc 4.6 (and newer versions) and enables it when a compiler supports rvalue references.

  • boost-trunk/boost/foreach.hpp

     
    3131
    3232// Some compilers let us detect even const-qualified rvalues at compile-time
    3333#if BOOST_WORKAROUND(BOOST_MSVC, >= 1310) && !defined(_PREFAST_)                                 \
    34  || (BOOST_WORKAROUND(__GNUC__, >= 4) && !defined(BOOST_INTEL) && !defined(BOOST_CLANG))         \
     34 || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) &&       \
     35                                                                  !defined(BOOST_CLANG))         \
    3536 || (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ >= 4) && !defined(BOOST_INTEL) &&       \
    36                                                                   !defined(BOOST_CLANG))
     37                                                                  !defined(BOOST_CLANG))         \
     38 || !defined(BOOST_NO_RVALUE_REFERENCES)
    3739# define BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION
    3840#else
    3941// Some compilers allow temporaries to be bound to non-const references.
     
    8082#include <boost/type_traits/is_const.hpp>
    8183#include <boost/type_traits/is_abstract.hpp>
    8284#include <boost/type_traits/is_base_and_derived.hpp>
     85#include <boost/type_traits/is_rvalue_reference.hpp>
    8386#include <boost/iterator/iterator_traits.hpp>
    8487#include <boost/utility/addressof.hpp>
    8588#include <boost/foreach_fwd.hpp>
     
    213216template<typename Bool1>
    214217inline boost::mpl::not_<Bool1> *not_(Bool1 *) { return 0; }
    215218
     219#ifdef BOOST_NO_RVALUE_REFERENCES
    216220template<typename T>
    217221inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; }
    218222
    219223template<typename T>
    220224inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; }
     225#else
     226template<typename T>
     227inline boost::is_rvalue_reference<T&&> *is_rvalue_(T&& t, int) { return 0; }
     228#endif
    221229
    222230template<typename T>
    223231inline boost::is_array<T> *is_array_(T const &) { return 0; }