yat  0.21pre
DataIterator.h
1 #ifndef _theplu_yat_utility_data_iterator_
2 #define _theplu_yat_utility_data_iterator_
3 
4 // $Id: DataIterator.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, 2015, 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/type_traits/remove_reference.hpp>
32 
33 namespace theplu {
34 namespace yat {
35 namespace utility {
36 
62  template<typename Base>
64  : public boost::iterator_adaptor<
65  DataIterator<Base> // Derived
66  , Base // Base
67  , typename boost::remove_reference<typename iterator_traits<Base>::data_reference>::type
68  , boost::use_default // CategoryOrTraversal
69  , typename iterator_traits<Base>::data_reference // Reference
70  >
71 
72  {
73  public:
77  explicit DataIterator(Base b)
78  : DataIterator::iterator_adaptor_(b)
79  {
80  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Base>));
81  }
82 
89  : DataIterator::iterator_adaptor_()
90  {
91  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Base>));
92  }
93 
101  template<typename B2>
103  typename boost::enable_if_convertible<B2, Base>::type* = 0 )
104  : DataIterator::iterator_adaptor_(other.base())
105  {
106  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Base>));
107  }
108 
115  { return iterator_traits<Base>().data(this->base()); }
116 
117  private:
118  };
119 
127  template<typename Base>
129  {
130  return DataIterator<Base>(base);
131  }
132 
133 
134 }}} // of namespace utility, yat, and theplu
135 
136 #endif
DataIterator(DataIterator< B2 > other, typename boost::enable_if_convertible< B2, Base >::type *=0)
Conversion constructor.
Definition: DataIterator.h:102
Concept check for Data Iterator.
Definition: concept_check.h:240
Definition: iterator_traits.h:412
The Department of Theoretical Physics namespace as we define it.
DataIterator.
Definition: DataIterator.h:63
DataIterator(void)
Default Constructor.
Definition: DataIterator.h:88
traits::data_reference data_reference
Definition: iterator_traits.h:425
DataIterator(Base b)
Constructor from Base iterator.
Definition: DataIterator.h:77
iterator_traits< Base >::data_reference operator*(void) const
Definition: DataIterator.h:114
DataIterator< Base > data_iterator(Base base)
convenient function to create DataIterator
Definition: DataIterator.h:128

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14