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-04-15 06:11:06


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

Comment (by mimomorin@…):

 Hmm, I cannot attach a patch for `foreach.hpp`...

 The patch I made does the following:

 (Note: contrary to C++0x range-based for,
 this does not allow mutable iteration over rvalue ranges;
 Non-const rvalue ranges are bounded to **const** rvalue references.)

 1. Adding a configuration macro
 * BOOST_FOREACH_USE_RVALUE_REFERENCE_BINDING
   * When a compiler supports rvalue references and `decltype`,
     this macro is defined and rvalue reference binding is used.

 2. Adding macros for auto declarations
 * BOOST_FOREACH_AUTO_OBJECT(NAME, EXPR)
   * Equivalent to `auto NAME = EXPR;`.
 * BOOST_FOREACH_AUTO_REF_REF(NAME, EXPR)
   * Equivalent to `auto && NAME = EXPR;`if EXPR is an lvalue.
   * Equivalent to `auto const && NAME = EXPR;`if EXPR is an rvalue.

 3. Adding overloaded functions
 * `begin`
 * `end`
   * For C-strings, this function returns `cstr_end_iterator`, which is
 defined as an empty struct.
     I also overloaded `operator !=` to support C-strings:
     {{{
     template <typename Iterator>
     inline bool operator !=(Iterator cur, cstr_end_iterator)
     {
         return *cur != 0;
     }
     }}}
 * `rbegin`
 * `rend`


 All the regression tests ran successfully with the following compilers
 (both in C++03 and C++0x modes):
 gcc-4.3.5, gcc-4.4.5, gcc-4.5.2, gcc-4.6.0, clang (TOT).

 Newly added tests (in `test_noncopyable_rvalue.patch`) ran successfully in
 a C++0x mode.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5475#comment:2>
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:06 UTC