1 // Copyright 2003 The Trustees of Indiana University.
2 
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)
6 
7 #include "boost/shared_container_iterator.hpp"
8 #include "boost/shared_ptr.hpp"
9 #include <algorithm>
10 #include <iterator>
11 #include <iostream>
12 #include <vector>
13 
14 
15 template <typename Iterator>
print_range_nl(Iterator begin,Iterator end)16 void print_range_nl (Iterator begin, Iterator end) {
17   typedef typename std::iterator_traits<Iterator>::value_type val;
18   std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
19   std::cout.put('\n');
20 }
21 
22 
main()23 int main() {
24 
25   typedef boost::shared_ptr< std::vector<int> > ints_t;
26   {
27     ints_t ints(new std::vector<int>());
28 
29     ints->push_back(0);
30     ints->push_back(1);
31     ints->push_back(2);
32     ints->push_back(3);
33     ints->push_back(4);
34     ints->push_back(5);
35 
36     print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
37                    boost::make_shared_container_iterator(ints->end(),ints));
38   }
39 
40 
41 
42   return 0;
43 }
44