yat  0.14.5pre
WeightIterator.h
1 #ifndef _theplu_yat_utility_weight_iterator_
2 #define _theplu_yat_utility_weight_iterator_
3 
4 // $Id: WeightIterator.h 3550 2017-01-03 05:41:02Z peter $
5 
6 /*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2014, 2016 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 "concept_check.h"
27 #include "iterator_traits.h"
28 
29 #include <boost/concept_check.hpp>
30 #include <boost/iterator/iterator_adaptor.hpp>
31 #include <boost/iterator/iterator_concepts.hpp>
32 #include <boost/type_traits/remove_reference.hpp>
33 
34 namespace theplu {
35 namespace yat {
36 namespace utility {
37 
63  template<typename Base>
65  : public boost::iterator_adaptor<
66  WeightIterator<Base> // Derived
67  , Base // Base
68  , typename boost::remove_reference<typename iterator_traits<Base>::weight_reference>::type
69  , boost::use_default // CategoryOrTraversal
70  , typename iterator_traits<Base>::weight_reference // Reference
71  >
72 
73  {
74  public:
81  : WeightIterator::iterator_adaptor_()
82  {
83  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Base>));
84  }
85 
89  explicit WeightIterator(Base b)
90  : WeightIterator::iterator_adaptor_(b)
91  {
92  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Base>));
93  }
94 
103  template<typename B2>
105  typename boost::enable_if_convertible<B2, Base>::type* = 0 )
106  : WeightIterator::iterator_adaptor_(other.base())
107  {
108  BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<Base>));
109  }
110 
117  { return iterator_traits<Base>().weight(this->base()); }
118 
119  private:
120  };
121 
129  template<typename Base>
131  {
132  return WeightIterator<Base>(base);
133  }
134 
135 
136 }}} // of namespace utility, yat, and theplu
137 
138 #endif
Concept check for Data Iterator.
Definition: concept_check.h:228
Definition: iterator_traits.h:412
iterator_traits< Base >::weight_reference operator*(void) const
Definition: WeightIterator.h:116
WeightIterator< Base > weight_iterator(Base base)
convenient function to create WeightIterator
Definition: WeightIterator.h:130
WeightIterator(Base b)
Constructor from Base iterator.
Definition: WeightIterator.h:89
traits::weight_reference weight_reference
Definition: iterator_traits.h:435
WeightIterator.
Definition: WeightIterator.h:64
WeightIterator(WeightIterator< B2 > other, typename boost::enable_if_convertible< B2, Base >::type *=0)
Conversion constructor.
Definition: WeightIterator.h:104
WeightIterator(void)
Default Constructor.
Definition: WeightIterator.h:80

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5