Boost logo

Boost-Commit :

From: troy_at_[hidden]
Date: 2008-06-29 11:39:21


Author: troy
Date: 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
New Revision: 46855
URL: http://svn.boost.org/trac/boost/changeset/46855

Log:
merge from release branch
Added:
   branches/CMake/release/libs/foreach/test/array_byref_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/array_byref_r.cpp
   branches/CMake/release/libs/foreach/test/array_byval_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/array_byval_r.cpp
   branches/CMake/release/libs/foreach/test/cstr_byref_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/cstr_byref_r.cpp
   branches/CMake/release/libs/foreach/test/cstr_byval_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/cstr_byval_r.cpp
   branches/CMake/release/libs/foreach/test/misc.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/misc.cpp
   branches/CMake/release/libs/foreach/test/pair_byref_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/pair_byref_r.cpp
   branches/CMake/release/libs/foreach/test/pair_byval_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/pair_byval_r.cpp
   branches/CMake/release/libs/foreach/test/rvalue_const_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/rvalue_const_r.cpp
   branches/CMake/release/libs/foreach/test/rvalue_nonconst_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/rvalue_nonconst_r.cpp
   branches/CMake/release/libs/foreach/test/stl_byref_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/stl_byref_r.cpp
   branches/CMake/release/libs/foreach/test/stl_byval_r.cpp
      - copied unchanged from r46809, /branches/release/libs/foreach/test/stl_byval_r.cpp
Text files modified:
   branches/CMake/release/libs/foreach/doc/foreach.qbk | 11 ++++++
   branches/CMake/release/libs/foreach/test/CMakeLists.txt | 13 +++++++
   branches/CMake/release/libs/foreach/test/Jamfile.v2 | 11 ++++++
   branches/CMake/release/libs/foreach/test/rvalue_const.cpp | 3 +
   branches/CMake/release/libs/foreach/test/utility.hpp | 64 ++++++++++++++++++++++++++++++++++++++++
   5 files changed, 100 insertions(+), 2 deletions(-)

Modified: branches/CMake/release/libs/foreach/doc/foreach.qbk
==============================================================================
--- branches/CMake/release/libs/foreach/doc/foreach.qbk (original)
+++ branches/CMake/release/libs/foreach/doc/foreach.qbk 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
@@ -162,6 +162,14 @@
         // Note: get_vector_float() will be called exactly once
     }
 
+Iterate in reverse:
+
+ std::list<int> list_int( /*...*/ );
+ BOOST_REVERSE_FOREACH( int i, list_int )
+ {
+ // do something with i
+ }
+
 Iterating over rvalues doesn't work on some older compilers. Check the
 [link foreach.portability Portability] section to see whether your
 compiler supports this.
@@ -174,7 +182,8 @@
 doesn't mean you're stuck with it, though. If you would like to use a different
 identifier (`foreach`, perhaps), you can simply do:
 
- #define foreach BOOST_FOREACH
+ #define foreach BOOST_FOREACH
+ #define reverse_foreach BOOST_REVERSE_FOREACH
 
 Only do this if you are sure that the identifier you choose will not cause
 name conflicts in your code.

Modified: branches/CMake/release/libs/foreach/test/CMakeLists.txt
==============================================================================
--- branches/CMake/release/libs/foreach/test/CMakeLists.txt (original)
+++ branches/CMake/release/libs/foreach/test/CMakeLists.txt 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
@@ -1,17 +1,28 @@
 set(TESTS
 stl_byval
+stl_byval_r
 stl_byref
+stl_byref_r
 array_byval
+array_byval_r
 array_byref
+array_byref_r
 cstr_byval
+cstr_byval_r
 cstr_byref
+cstr_byref_r
 pair_byval
+pair_byval_r
 pair_byref
+pair_byref_r
 user_defined
 call_once
 rvalue_const
+rvalue_const_r
 rvalue_nonconst
-dependent_type)
+rvalue_nonconst_r
+dependent_type
+misc)
 
 foreach(test ${TESTS})
   boost_test_run(${test})

Modified: branches/CMake/release/libs/foreach/test/Jamfile.v2
==============================================================================
--- branches/CMake/release/libs/foreach/test/Jamfile.v2 (original)
+++ branches/CMake/release/libs/foreach/test/Jamfile.v2 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
@@ -8,16 +8,27 @@
 test-suite "foreach"
     : [ run stl_byval.cpp ]
       [ run stl_byref.cpp ]
+ [ run stl_byval_r.cpp ]
+ [ run stl_byref_r.cpp ]
       [ run array_byval.cpp ]
       [ run array_byref.cpp ]
+ [ run array_byval_r.cpp ]
+ [ run array_byref_r.cpp ]
       [ run cstr_byval.cpp ]
       [ run cstr_byref.cpp ]
+ [ run cstr_byval_r.cpp ]
+ [ run cstr_byref_r.cpp ]
       [ run pair_byval.cpp ]
       [ run pair_byref.cpp ]
+ [ run pair_byval_r.cpp ]
+ [ run pair_byref_r.cpp ]
       [ run user_defined.cpp ]
       [ run call_once.cpp ]
       [ run rvalue_const.cpp ]
       [ run rvalue_nonconst.cpp ]
+ [ run rvalue_const_r.cpp ]
+ [ run rvalue_nonconst_r.cpp ]
       [ run dependent_type.cpp ]
+ [ run misc.cpp ]
       [ compile noncopyable.cpp ]
     ;

Modified: branches/CMake/release/libs/foreach/test/rvalue_const.cpp
==============================================================================
--- branches/CMake/release/libs/foreach/test/rvalue_const.cpp (original)
+++ branches/CMake/release/libs/foreach/test/rvalue_const.cpp 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
@@ -13,7 +13,10 @@
 #include <boost/foreach.hpp>
 
 #ifdef BOOST_FOREACH_NO_CONST_RVALUE_DETECTION
+// ignore error during Microsoft Code Analysis
+#if !defined(_PREFAST_)
 # error Expected failure : const rvalues disallowed
+#endif
 #else
 
 std::vector<int> const get_vector()

Modified: branches/CMake/release/libs/foreach/test/utility.hpp
==============================================================================
--- branches/CMake/release/libs/foreach/test/utility.hpp (original)
+++ branches/CMake/release/libs/foreach/test/utility.hpp 2008-06-29 11:39:20 EDT (Sun, 29 Jun 2008)
@@ -76,4 +76,68 @@
     }
 }
 
+
+///////////////////////////////////////////////////////////////////////////////
+// sequence_equal_byval_n_r
+inline bool sequence_equal_byval_n_r( foreach_container_type & rng, char const * result )
+{
+ BOOST_REVERSE_FOREACH( foreach_value_type i, rng )
+ {
+ if(0 == *result || i != *result)
+ return false;
+ ++result;
+ }
+ return 0 == *result;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// sequence_equal_byval_c_r
+inline bool sequence_equal_byval_c_r( foreach_const_container_type & rng, char const * result )
+{
+ BOOST_REVERSE_FOREACH( foreach_value_type i, rng )
+ {
+ if(0 == *result || i != *result)
+ return false;
+ ++result;
+ }
+ return 0 == *result;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// sequence_equal_byref_n_r
+inline bool sequence_equal_byref_n_r( foreach_container_type & rng, char const * result )
+{
+ BOOST_REVERSE_FOREACH( foreach_reference_type i, rng )
+ {
+ if(0 == *result || i != *result)
+ return false;
+ ++result;
+ }
+ return 0 == *result;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// sequence_equal_byref_c_r
+inline bool sequence_equal_byref_c_r( foreach_const_container_type & rng, char const * result )
+{
+ BOOST_REVERSE_FOREACH( foreach_const_reference_type i, rng )
+ {
+ if(0 == *result || i != *result)
+ return false;
+ ++result;
+ }
+ return 0 == *result;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// mutate_foreach_byref
+//
+inline void mutate_foreach_byref_r( foreach_container_type & rng )
+{
+ BOOST_REVERSE_FOREACH( foreach_reference_type i, rng )
+ {
+ ++i;
+ }
+}
+
 #endif


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