Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/utility/shared_iterator_example3.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.0 KB
Line 
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 "boost/tuple/tuple.hpp" // for boost::tie
10#include <algorithm>              // for std::copy
11#include <iostream>              
12#include <vector>
13
14
15typedef boost::shared_container_iterator< std::vector<int> > iterator;
16
17std::pair<iterator,iterator>
18return_range() {
19  boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
20  range->push_back(0);
21  range->push_back(1);
22  range->push_back(2);
23  range->push_back(3);
24  range->push_back(4);
25  range->push_back(5);
26  return boost::make_shared_container_range(range);
27}
28
29
30int main() {
31
32
33  iterator i,end;
34 
35  boost::tie(i,end) = return_range();
36
37  std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
38  std::cout.put('\n');
39
40  return 0;
41}
Note: See TracBrowser for help on using the repository browser.