Changeset 1365 for trunk/yat/utility/DataIterator.h
 Timestamp:
 Jul 10, 2008, 10:30:07 PM (14 years ago)
 File:

 1 moved
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/DataIterator.h
r1363 r1365 1 #ifndef _theplu_yat_utility_ iterator_data_2 #define _theplu_yat_utility_ iterator_data_1 #ifndef _theplu_yat_utility_data_iterator_ 2 #define _theplu_yat_utility_data_iterator_ 3 3 4 4 // $Id$ … … 25 25 */ 26 26 27 #include "yat_assert.h"27 #include <boost/iterator/iterator_adaptor.hpp> 28 28 29 29 namespace theplu { … … 32 32 33 33 /** 34 @brief Iterator34 @brief DataIterator 35 35 */ 36 template<typename T> 37 class IteratorData 36 template<typename Base> 37 class DataIterator 38 : public boost::iterator_adaptor< 39 DataIterator<Base> // Derived 40 , Base // Base 41 , double // Value 42 , boost::forward_traversal_tag // CategoryOrTraversal 43 , double 44 > 45 38 46 { 39 47 public: 40 IteratorData(T); 48 explicit DataIterator(Base b) 49 : DataIterator::iterator_adaptor_(b) {} 50 51 double operator*(void) const 52 { return iterator_traits<Base>().data(this>base()); } 41 53 42 54 private: 43 T base_;44 55 }; 45 56 46 template<typename T> 47 IteratorData<T>::IteratorData(T base) 48 : base_(base) 49 {} 57 /** 58 \brief convenient function to create DataIterator 59 60 Convenient function in same fashion as std::make_pair. 61 */ 62 template<typename Base> 63 DataIterator<Base> make_data_iterator(Base base) 64 { 65 return DataIterator<Base>(base); 66 } 67 50 68 51 69
Note: See TracChangeset
for help on using the changeset viewer.