]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/foreach/test/stl_byref_r.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / foreach / test / stl_byref_r.cpp
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)
5
6 /*
7 Revision history:
8 25 August 2005: Initial version.
9 */
10
11 #include <list>
12 #include <boost/core/lightweight_test.hpp>
13 #include <boost/foreach.hpp>
14
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;
22
23 #include "./utility.hpp"
24
25 ///////////////////////////////////////////////////////////////////////////////
26 // initialize a std::list<int>
27 std::list<int> make_list()
28 {
29 std::list<int> l;
30 l.push_back(1);
31 l.push_back(2);
32 l.push_back(3);
33 l.push_back(4);
34 l.push_back(5);
35 return l;
36 }
37
38 ///////////////////////////////////////////////////////////////////////////////
39 // define some containers
40 //
41 std::list<int> my_list = make_list();
42 std::list<int> const &my_const_list = my_list;
43
44 ///////////////////////////////////////////////////////////////////////////////
45 // test_main
46 //
47 int main()
48 {
49 // non-const containers by reference
50 BOOST_TEST(sequence_equal_byref_n_r(my_list, "\5\4\3\2\1"));
51
52 // const containers by reference
53 BOOST_TEST(sequence_equal_byref_c_r(my_const_list, "\5\4\3\2\1"));
54
55 // mutate the mutable collections
56 mutate_foreach_byref_r(my_list);
57
58 // compare the mutated collections to the actual results
59 BOOST_TEST(sequence_equal_byref_n_r(my_list, "\6\5\4\3\2"));
60
61 return boost::report_errors();
62 }