yat  0.10.4pre
DataIterator.h
1 #ifndef _theplu_yat_utility_data_iterator_
2 #define _theplu_yat_utility_data_iterator_
3 
4 // $Id: DataIterator.h 2282 2010-06-26 01:38:17Z 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  DataIterator<Base> // Derived
64  , Base // Base
65  , typename boost::remove_reference<typename iterator_traits<Base>::data_reference>::type
66  , boost::use_default // CategoryOrTraversal
67  , typename iterator_traits<Base>::data_reference // Reference
68  >
69 
70  {
71  public:
75  explicit DataIterator(Base b)
76  : DataIterator::iterator_adaptor_(b)
77  {
78  BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
79  }
80 
87  : DataIterator::iterator_adaptor_()
88  {
89  BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
90  }
91 
99  template<typename B2>
101  typename boost::enable_if_convertible<B2, Base>::type* = 0 )
102  : DataIterator::iterator_adaptor_(other.base()) {}
103 
110  { return iterator_traits<Base>().data(this->base()); }
111 
112  private:
113  };
114 
122  template<typename Base>
123  DataIterator<Base> data_iterator(Base base)
124  {
125  return DataIterator<Base>(base);
126  }
127 
128 
129 
130 }}} // of namespace utility, yat, and theplu
131 
132 #endif

Generated on Mon Nov 11 2013 09:41:44 for yat by  doxygen 1.8.1