]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/iterator/permutation_iterator.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
05c740d348b3bddc255e27e36350187e035f5657
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / iterator / permutation_iterator.hpp
1 // (C) Copyright Toon Knapen    2001.\r
2 // (C) Copyright David Abrahams 2003.\r
3 // (C) Copyright Roland Richter 2003.\r
4 // Distributed under the Boost Software License, Version 1.0. (See\r
5 // accompanying file LICENSE_1_0.txt or copy at\r
6 // http://www.boost.org/LICENSE_1_0.txt)\r
7 \r
8 #ifndef BOOST_PERMUTATION_ITERATOR_HPP\r
9 #define BOOST_PERMUTATION_ITERATOR_HPP\r
10 \r
11 #include <iterator>\r
12 \r
13 #include <boost/iterator/iterator_adaptor.hpp>\r
14 \r
15 \r
16 namespace boost\r
17 {\r
18 \r
19 template< class ElementIterator\r
20         , class IndexIterator>\r
21 class permutation_iterator\r
22   : public iterator_adaptor< \r
23              permutation_iterator<ElementIterator, IndexIterator>\r
24            , IndexIterator, typename detail::iterator_traits<ElementIterator>::value_type\r
25            , use_default, typename detail::iterator_traits<ElementIterator>::reference>\r
26 {\r
27   typedef iterator_adaptor< \r
28             permutation_iterator<ElementIterator, IndexIterator>\r
29           , IndexIterator, typename detail::iterator_traits<ElementIterator>::value_type\r
30           , use_default, typename detail::iterator_traits<ElementIterator>::reference> super_t;\r
31 \r
32   friend class iterator_core_access;\r
33 \r
34 public:\r
35   permutation_iterator() : m_elt_iter() {}\r
36 \r
37   explicit permutation_iterator(ElementIterator x, IndexIterator y) \r
38       : super_t(y), m_elt_iter(x) {}\r
39 \r
40   template<class OtherElementIterator, class OtherIndexIterator>\r
41   permutation_iterator(\r
42       permutation_iterator<OtherElementIterator, OtherIndexIterator> const& r\r
43       , typename enable_if_convertible<OtherElementIterator, ElementIterator>::type* = 0\r
44       , typename enable_if_convertible<OtherIndexIterator, IndexIterator>::type* = 0\r
45       )\r
46     : super_t(r.base()), m_elt_iter(r.m_elt_iter)\r
47   {}\r
48 \r
49 private:\r
50     typename super_t::reference dereference() const\r
51         { return *(m_elt_iter + *this->base()); }\r
52 \r
53 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS\r
54     template <class,class> friend class permutation_iterator;\r
55 #else\r
56  public:\r
57 #endif \r
58     ElementIterator m_elt_iter;\r
59 };\r
60 \r
61 \r
62 template <class ElementIterator, class IndexIterator>\r
63 permutation_iterator<ElementIterator, IndexIterator> \r
64 make_permutation_iterator( ElementIterator e, IndexIterator i )\r
65 {\r
66     return permutation_iterator<ElementIterator, IndexIterator>( e, i );\r
67 }\r
68 \r
69 \r
70 } // namespace boost\r
71 \r
72 #endif\r