yat  0.12.3pre
WeightIterator.h
1 #ifndef _theplu_yat_utility_weight_iterator_
2 #define _theplu_yat_utility_weight_iterator_
3 
4 // $Id: WeightIterator.h 2992 2013-03-03 05:03:44Z peter $
5 
6 /*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010 Peter Johansson
9 
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11 
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16 
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #include "iterator_traits.h"
27 
28 #include <boost/concept_check.hpp>
29 #include <boost/iterator/iterator_adaptor.hpp>
30 #include <boost/type_traits/remove_reference.hpp>
31 
32 namespace theplu {
33 namespace yat {
34 namespace utility {
35 
60  template<typename Base>
62  : public boost::iterator_adaptor<
63  WeightIterator<Base> // Derived
64  , Base // Base
65  , typename boost::remove_reference<typename iterator_traits<Base>::weight_reference>::type
66  , boost::use_default // CategoryOrTraversal
67  , typename iterator_traits<Base>::weight_reference // Reference
68  >
69 
70  {
71  public:
78  : WeightIterator::iterator_adaptor_()
79  {
80  BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
81  }
82 
86  explicit WeightIterator(Base b)
87  : WeightIterator::iterator_adaptor_(b)
88  {
89  BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
90  }
91 
100  template<typename B2>
102  typename boost::enable_if_convertible<B2, Base>::type* = 0 )
103  : WeightIterator::iterator_adaptor_(other.base()) {}
104 
111  { return iterator_traits<Base>().weight(this->base()); }
112 
113  private:
114  };
115 
123  template<typename Base>
125  {
126  return WeightIterator<Base>(base);
127  }
128 
129 
130 
131 }}} // of namespace utility, yat, and theplu
132 
133 #endif
Definition: iterator_traits.h:406
iterator_traits< Base >::weight_reference operator*(void) const
Definition: WeightIterator.h:110
WeightIterator< Base > weight_iterator(Base base)
convenient function to create WeightIterator
Definition: WeightIterator.h:124
WeightIterator(Base b)
Constructor from Base iterator.
Definition: WeightIterator.h:86
traits::weight_reference weight_reference
Definition: iterator_traits.h:429
WeightIterator.
Definition: WeightIterator.h:61
WeightIterator(WeightIterator< B2 > other, typename boost::enable_if_convertible< B2, Base >::type *=0)
Conversion constructor.
Definition: WeightIterator.h:101
WeightIterator(void)
Default Constructor.
Definition: WeightIterator.h:77

Generated on Mon Jun 1 2015 12:29:52 for yat by  doxygen 1.8.5