Changeset 2159
- Timestamp:
- Jan 20, 2010, 12:48:24 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/averager_test.cc
r2121 r2159 30 30 #include "yat/statistics/AveragerWeighted.h" 31 31 #include "yat/utility/Vector.h" 32 33 #include <boost/concept_archetype.hpp> 32 34 33 35 #include <cmath> … … 359 361 suite.err() << "error for x_averager():\t" << std::endl; 360 362 } 363 364 // compile tests should not be run 365 if (false) { 366 Averager averager; 367 add(averager, boost::input_iterator_archetype<double>(), 368 boost::input_iterator_archetype<double>()); 369 AveragerWeighted averagerw; 370 using utility::DataWeight; 371 typedef boost::input_iterator_archetype<DataWeight> Iter; 372 Iter iter; 373 utility::iterator_traits<Iter> traits; 374 //traits.weight(iter); 375 // add(averagerw, boost::input_iterator_archetype<DataWeight>(), 376 // boost::input_iterator_archetype<DataWeight>()); 377 } 378 361 379 return ok; 362 380 } -
trunk/test/iterator_test.cc
r2151 r2159 30 30 #include "yat/utility/Container2DIterator.h" 31 31 #include "yat/utility/DataWeight.h" 32 #include "yat/utility/DataWeightProxy.h" 32 33 #include "yat/utility/DataIterator.h" 33 34 #include "yat/utility/Matrix.h" … … 297 298 double w = traits.weight(vec.begin()); 298 299 suite.add(suite.equal(w, 1.0)); 300 utility::iterator_traits<utility::DataWeight*>().weight(&vec[0]); 301 302 double* trivial_iter = new double(1.0); 303 utility::DataWeightProxy<double*, double*> dwp(trivial_iter,trivial_iter); 304 typedef utility::DataWeightProxy<double*, double*> Proxy; 305 //utility::iterator_traits<Proxy*> traits2; 306 //traits2.weight(&dwp); 307 delete trivial_iter; 299 308 } 300 309 -
trunk/yat/statistics/Averager.h
r2119 r2159 27 27 28 28 #include "yat/utility/iterator_traits.h" 29 30 #include <boost/concept_check.hpp> 29 31 30 32 #include <cmath> … … 186 188 \relates Averager 187 189 */ 188 template <typename I ter>189 void add(Averager& a, I ter first, Iter last)190 template <typename InputIterator> 191 void add(Averager& a, InputIterator first, InputIterator last) 190 192 { 193 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>)); 191 194 utility::check_iterator_is_unweighted(first); 192 195 for ( ; first != last; ++first) -
trunk/yat/statistics/AveragerWeighted.h
r2119 r2159 216 216 \relates AveragerWeighted 217 217 */ 218 template <typename I ter>219 void add(AveragerWeighted& a, I ter first,Iter last)218 template <typename InputIter> 219 void add(AveragerWeighted& a, InputIter first, InputIter last) 220 220 { 221 utility::iterator_traits<InputIter> traits; 221 222 for ( ; first != last; ++first) 222 a.add(utility::iterator_traits<Iter>().data(first), 223 utility::iterator_traits<Iter>().weight(first)); 223 a.add(traits.data(first), traits.weight(first)); 224 224 } 225 225 -
trunk/yat/utility/iterator_traits.h
r2151 r2159 25 25 26 26 #include "DataWeight.h" 27 28 #include <boost/type_traits/is_convertible.hpp> 29 #include <boost/utility/enable_if.hpp> 27 30 28 31 #include <iterator> … … 53 56 used in weighted_iterator_traits 54 57 */ 55 template <typename T >58 template <typename T, typename Enable = void> 56 59 struct weighted_iterator_traits_detail { 57 60 /** … … 66 69 specialization for iterators with value type DataWeight 67 70 */ 68 template < >69 struct weighted_iterator_traits_detail< DataWeight> {71 template <typename T> 72 struct weighted_iterator_traits_detail<T, typename boost::enable_if<typename boost::is_convertible<T, DataWeight>::type>::type > { 70 73 /** 71 74 Iterators with value type DataWeight is weighted … … 73 76 typedef weighted_iterator_tag type; 74 77 }; 78 75 79 } // namespace detail 76 80
Note: See TracChangeset
for help on using the changeset viewer.