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 | |
---|
15 | typedef boost::shared_container_iterator< std::vector<int> > iterator; |
---|
16 | |
---|
17 | std::pair<iterator,iterator> |
---|
18 | return_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 | |
---|
30 | int 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.