Changeset 2068
- Timestamp:
- Sep 17, 2009, 11:12:21 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r2065 r2068 5 5 Version 0.6 (released DATE) 6 6 7 - pair_first_iterator and pair_second_iterator now work with 8 const_iterator (ticket:562) 7 9 - Passing by const& in KolmogorovSmirnov::Element::operator< (r2064) 8 10 - classes OptionInFile and OptionOutFile are deprecated (ticket:521) -
trunk/test/iterator_test.cc
r1877 r2068 45 45 #include <fstream> 46 46 #include <iterator> 47 #include <map> 48 #include <set> 47 49 #include <string> 48 50 #include <vector> … … 59 61 60 62 void test_boost_util(test::Suite&); 63 void test_pair_second_iterator(test::Suite&); 61 64 62 65 void test_stride_iterator(test::Suite& suite); … … 72 75 old_main(suite); 73 76 test_boost_util(suite); 77 test_pair_second_iterator(suite); 74 78 test_weighted_iterator(suite); 75 79 return suite.return_value(); … … 360 364 } 361 365 366 void test_pair_second_iterator(test::Suite& suite) 367 { 368 typedef std::map<std::string, std::string> C; 369 C person2color; 370 person2color["me"] = "yellow"; 371 person2color["you"] = "orange"; 372 373 C::const_iterator cbegin = person2color.begin(); 374 C::const_iterator cend = person2color.end(); 375 376 std::set<std::string> colors; 377 colors.insert(utility::pair_second_iterator(cbegin), 378 utility::pair_second_iterator(cend)); 379 380 suite.test_bidirectional_iterator(utility::pair_second_iterator(cbegin)); 381 suite.test_bidirectional_iterator(utility::pair_first_iterator(cbegin)); 382 } -
trunk/yat/utility/stl_utility.h
r2010 r2068 39 39 #include <boost/iterator/transform_iterator.hpp> 40 40 #include <boost/mpl/if.hpp> 41 #include <boost/type_traits/add_const.hpp> 41 42 #include <boost/type_traits/is_const.hpp> 42 #include <boost/type_traits/ add_const.hpp>43 #include <boost/type_traits/remove_reference.hpp> 43 44 44 45 #include <algorithm> … … 432 433 template<class Iter> 433 434 boost::transform_iterator< 434 PairFirst<typename std::iterator_traits<Iter>::value_type>, 435 PairFirst<typename boost::remove_reference< 436 typename std::iterator_traits<Iter>::reference 437 >::type>, 435 438 Iter> pair_first_iterator(Iter i) 436 439 { 437 typedef PairFirst<typename std::iterator_traits<Iter>::value_type> PF; 440 // We are going via ::reference in order to remain const info; 441 // ::value_type does not contain const information. 442 typedef typename std::iterator_traits<Iter>::reference ref_type; 443 typedef typename boost::remove_reference<ref_type>::type val_type; 444 typedef PairFirst<val_type> PF; 438 445 return boost::transform_iterator<PF, Iter>(i, PF()); 439 446 } … … 457 464 template<class Iter> 458 465 boost::transform_iterator< 459 PairSecond<typename std::iterator_traits<Iter>::value_type>, 466 PairSecond<typename boost::remove_reference< 467 typename std::iterator_traits<Iter>::reference 468 >::type>, 460 469 Iter> pair_second_iterator(Iter i) 461 470 { 462 typedef PairSecond<typename std::iterator_traits<Iter>::value_type> PF; 463 return boost::transform_iterator<PF, Iter>(i, PF()); 471 // We are going via ::reference in order to remain const info; 472 // ::value_type does not contain const information. 473 typedef typename std::iterator_traits<Iter>::reference ref_type; 474 typedef typename boost::remove_reference<ref_type>::type val_type; 475 typedef PairSecond<val_type> PS; 476 return boost::transform_iterator<PS, Iter>(i, PS()); 464 477 } 465 478
Note: See TracChangeset
for help on using the changeset viewer.