1
// Copyright 2003 The Trustees of Indiana University.
3
// Use, modification and distribution is subject to the Boost Software
4
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
7
// Shared container iterator adaptor
8
// Author: Ronald Garcia
9
// See http://boost.org/libs/utility/shared_container_iterator.html
13
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
17
#include "boost/shared_container_iterator.hpp"
18
#include "boost/shared_ptr.hpp"
24
resource() { ++count; }
25
resource(resource const&) { ++count; }
26
~resource() { --count; }
28
int resource::count = 0;
30
typedef std::vector<resource> resources_t;
32
typedef boost::shared_container_iterator< resources_t > iterator;
35
void set_range(iterator& i, iterator& end) {
37
boost::shared_ptr< resources_t > objs(new resources_t());
39
for (int j = 0; j != 6; ++j)
40
objs->push_back(resource());
42
i = iterator(objs->begin(),objs);
43
end = iterator(objs->end(),objs);
44
assert(resource::count == 6);
50
assert(resource::count == 0);
57
assert(resource::count == 6);
59
assert(resource::count == 6);
61
assert(resource::count == 0);