Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/shared_container_iterator.hpp @ 58

Last change on this file since 58 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.0 KB
Line 
1// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and
2// distribute this software is granted provided this copyright notice appears
3// in all copies. This software is provided "as is" without express or implied
4// warranty, and with no claim as to its suitability for any purpose.
5
6// See http://www.boost.org/libs/utility/shared_container_iterator.html for documentation.
7
8#ifndef SHARED_CONTAINER_ITERATOR_RG08102002_HPP
9#define SHARED_CONTAINER_ITERATOR_RG08102002_HPP
10
11#include "boost/iterator_adaptors.hpp"
12#include "boost/shared_ptr.hpp"
13#include <utility>
14
15namespace boost {
16
17template <typename Container>
18class shared_container_iterator : public iterator_adaptor<
19                                    shared_container_iterator<Container>,
20                                    typename Container::iterator> {
21
22  typedef iterator_adaptor<
23    shared_container_iterator<Container>,
24    typename Container::iterator> super_t;
25
26  typedef typename Container::iterator iterator_t;
27  typedef boost::shared_ptr<Container> container_ref_t;
28
29  container_ref_t container_ref;
30public:
31  shared_container_iterator() { }
32
33  shared_container_iterator(iterator_t const& x,container_ref_t const& c) :
34    super_t(x), container_ref(c) { }
35
36
37};
38
39template <typename Container>
40shared_container_iterator<Container>
41make_shared_container_iterator(typename Container::iterator iter,
42                               boost::shared_ptr<Container> const& container) {
43  typedef shared_container_iterator<Container> iterator;
44  return iterator(iter,container);
45}
46
47
48
49template <typename Container>
50std::pair<
51  shared_container_iterator<Container>,
52  shared_container_iterator<Container> >
53make_shared_container_range(boost::shared_ptr<Container> const& container) {
54  return
55    std::make_pair(
56      make_shared_container_iterator(container->begin(),container),
57      make_shared_container_iterator(container->end(),container));
58}
59
60
61} // namespace boost
62#endif  // SHARED_CONTAINER_ITERATOR_RG08102002_HPP
Note: See TracBrowser for help on using the repository browser.