Ticket #5473: test_mutate_rvalue.patch

File test_mutate_rvalue.patch, 1.5 KB (added by mimomorin@…, 12 years ago)

Add mutate_rvalue.cpp and update Jamfile (a patch for libs/foreach/test/ against trunk).

  • libs/foreach/test/Jamfile.v2

     
    3030      [ run rvalue_nonconst.cpp ]
    3131      [ run rvalue_const_r.cpp ]
    3232      [ run rvalue_nonconst_r.cpp ]
     33      [ run mutate_rvalue.cpp ]
    3334      [ run dependent_type.cpp ]
    3435      [ run misc.cpp ]
    3536      [ compile noncopyable.cpp ]
  • libs/foreach/test/mutate_rvalue.cpp

     
     1//  (C) Copyright Eric Niebler 2005.
     2//  Use, modification and distribution are subject to the
     3//  Boost Software License, Version 1.0. (See accompanying file
     4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     5
     6/*
     7  Revision history:
     8  25 August 2005 : Initial version.
     9*/
     10
     11#include <vector>
     12#include <boost/test/minimal.hpp>
     13#include <boost/foreach.hpp>
     14
     15#ifdef BOOST_FOREACH_NO_RVALUE_DETECTION
     16# error Expected failure : rvalues disallowed
     17#else
     18
     19std::vector<int> get_vector()
     20{
     21    return std::vector<int>(4, 4);
     22}
     23
     24///////////////////////////////////////////////////////////////////////////////
     25// test_main
     26//   
     27int test_main( int, char*[] )
     28{
     29    int counter = 0;
     30
     31    BOOST_FOREACH(int &i, get_vector())
     32    {
     33        ++i;
     34        counter += i;
     35    }
     36
     37    BOOST_CHECK(20 == counter);
     38
     39    return 0;
     40}
     41
     42#endif