1 // (C) Copyright Eric Niebler 2004.
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)
8 25 August 2005: Initial version.
12 #include <boost/core/lightweight_test.hpp>
13 #include <boost/foreach.hpp>
15 ///////////////////////////////////////////////////////////////////////////////
16 // define the container types, used by utility.hpp to generate the helper functions
17 typedef std::list
<int> foreach_container_type
;
18 typedef std::list
<int> const foreach_const_container_type
;
19 typedef int foreach_value_type
;
20 typedef int &foreach_reference_type
;
21 typedef int const &foreach_const_reference_type
;
23 #include "./utility.hpp"
25 ///////////////////////////////////////////////////////////////////////////////
26 // initialize a std::list<int>
27 std::list
<int> make_list()
38 ///////////////////////////////////////////////////////////////////////////////
39 // define some containers
41 std::list
<int> my_list
= make_list();
42 std::list
<int> const &my_const_list
= my_list
;
44 ///////////////////////////////////////////////////////////////////////////////
49 // non-const containers by reference
50 BOOST_TEST(sequence_equal_byref_n_r(my_list
, "\5\4\3\2\1"));
52 // const containers by reference
53 BOOST_TEST(sequence_equal_byref_c_r(my_const_list
, "\5\4\3\2\1"));
55 // mutate the mutable collections
56 mutate_foreach_byref_r(my_list
);
58 // compare the mutated collections to the actual results
59 BOOST_TEST(sequence_equal_byref_n_r(my_list
, "\6\5\4\3\2"));
61 return boost::report_errors();