Re: [Boost-bugs] [Boost C++ Libraries] #5475: [Foreach] rvalue reference binding of temporary ranges

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5475: [Foreach] rvalue reference binding of temporary ranges
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-10-16 12:20:54


#5475: [Foreach] rvalue reference binding of temporary ranges
--------------------------------------+-------------------------------------
  Reporter: mimomorin@… | Owner: eric_niebler
      Type: Patches | Status: closed
 Milestone: To Be Determined | Component: foreach
   Version: Boost Development Trunk | Severity: Problem
Resolution: fixed | Keywords: foreach, C++0x
--------------------------------------+-------------------------------------

Comment (by Michel Morin <mimomorin@…>):

 Attached a patch that implements C of comment 23.
 This patch should only affect a C++0x mode of gcc-4.4.

 I ported the code in this
 [[http://lists.boost.org/Archives/boost/2011/04/180591.php|post]].
 But, due to `auto&&` bug in gcc-4.4, I needed to change the code for
 adding `const` qualification to rvalue ranges.
 With this patch, `BOOST_FOREACH(DECL, EXPR)` does the following in a C++0x
 mode of gcc-4.4:

 1. Expand EXPR's lifetime
 {{{
 auto && tmp = EXPR
 }}}
 2. Add const if EXPR is rvalue
 {{{
 auto && rng = add_const_if< boost::is_rvalue_reference<decltype( (EXPR)
 )&&> >(tmp)
 }}}
 3. Do the usual range-based for loop over `rng`

 `libs/foreach/test/` ran successfully on gcc (4.3 - 4.6 and 4.7
 (experimental)) and clang (3.1(trunk) and Apple version 2.1) both in C++03
 and C++11 modes.
 I also tested `libs/spirit/test/karma/actions.cpp` on gcc-4.4 in a C++11
 mode
 and it ran fine.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5475#comment:24>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC