Ticket #3684: zip_iterator.patch
File zip_iterator.patch, 10.6 KB (added by , 13 years ago) |
---|
-
libs/iterator/test/zip_iterator_test.cpp
47 47 #include <list> 48 48 #include <set> 49 49 #include <functional> 50 #include <boost/ tuple/tuple.hpp>50 #include <boost/fusion/tuple.hpp> 51 51 #include <boost/iterator/transform_iterator.hpp> 52 52 #include <boost/iterator/is_readable_iterator.hpp> 53 53 #include <boost/type_traits/is_same.hpp> … … 104 104 105 105 typedef 106 106 boost::zip_iterator< 107 boost:: tuples::tuple<107 boost::fusion::tuple< 108 108 std::set<int>::iterator 109 109 , std::vector<double>::iterator 110 110 > 111 111 > zit_mixed; 112 112 113 113 zit_mixed zip_it_mixed = zit_mixed( 114 boost::make_tuple(114 boost::fusion::make_tuple( 115 115 intset.begin() 116 116 , vect1.begin() 117 117 ) 118 118 ); 119 119 120 boost:: tuples::tuple<int, double> val_tuple(120 boost::fusion::tuple<int, double> val_tuple( 121 121 *zip_it_mixed); 122 122 123 boost:: tuples::tuple<const int&, double&> ref_tuple(123 boost::fusion::tuple<const int&, double&> ref_tuple( 124 124 *zip_it_mixed); 125 125 126 double dblOldVal = boost:: tuples::get<1>(ref_tuple);127 boost:: tuples::get<1>(ref_tuple) -= 41.;126 double dblOldVal = boost::fusion::get<1>(ref_tuple); 127 boost::fusion::get<1>(ref_tuple) -= 41.; 128 128 129 if( 52 == boost:: tuples::get<0>(val_tuple) &&130 42. == boost:: tuples::get<1>(val_tuple) &&131 52 == boost:: tuples::get<0>(ref_tuple) &&132 1. == boost:: tuples::get<1>(ref_tuple) &&129 if( 52 == boost::fusion::get<0>(val_tuple) && 130 42. == boost::fusion::get<1>(val_tuple) && 131 52 == boost::fusion::get<0>(ref_tuple) && 132 1. == boost::fusion::get<1>(ref_tuple) && 133 133 1. == *vect1.begin() 134 134 ) 135 135 { … … 143 143 } 144 144 145 145 // Undo change to vect1 146 boost:: tuples::get<1>(ref_tuple) = dblOldVal;146 boost::fusion::get<1>(ref_tuple) = dblOldVal; 147 147 148 148 ///////////////////////////////////////////////////////////////////////////// 149 149 // … … 185 185 ve4.push_back(12); 186 186 187 187 // typedefs for cons lists of iterators. 188 typedef boost:: tuples::cons<188 typedef boost::fusion::cons< 189 189 std::set<int>::iterator, 190 boost:: tuples::tuple<190 boost::fusion::tuple< 191 191 std::vector<int>::iterator, 192 192 std::list<int>::iterator, 193 193 std::set<int>::iterator, … … 201 201 >::inherited 202 202 > cons_11_its_type; 203 203 // 204 typedef boost:: tuples::cons<204 typedef boost::fusion::cons< 205 205 std::list<int>::const_iterator, 206 206 cons_11_its_type 207 207 > cons_12_its_type; 208 208 209 209 // typedefs for cons lists for dereferencing the zip iterator 210 210 // made from the cons list above. 211 typedef boost:: tuples::cons<211 typedef boost::fusion::cons< 212 212 const int&, 213 boost:: tuples::tuple<213 boost::fusion::tuple< 214 214 int&, 215 215 int&, 216 216 const int&, … … 224 224 >::inherited 225 225 > cons_11_refs_type; 226 226 // 227 typedef boost:: tuples::cons<227 typedef boost::fusion::cons< 228 228 const int&, 229 229 cons_11_refs_type 230 230 > cons_12_refs_type; … … 238 238 li1.begin(), 239 239 cons_11_its_type( 240 240 se1.begin(), 241 boost:: make_tuple(241 boost::fusion::make_tuple( 242 242 ve1.begin(), 243 243 li2.begin(), 244 244 se2.begin(), … … 256 256 257 257 // Dereference, mess with the result a little. 258 258 cons_12_refs_type zip_it_12_dereferenced(*zip_it_12); 259 boost:: tuples::get<9>(zip_it_12_dereferenced) = 42;259 boost::fusion::get<9>(zip_it_12_dereferenced) = 42; 260 260 261 261 // Make a copy and move it a little to force some instantiations. 262 262 zip_it_12_type zip_it_12_copy(zip_it_12); 263 263 ++zip_it_12_copy; 264 264 265 if( boost:: tuples::get<11>(zip_it_12.get_iterator_tuple()) == ve4.begin() &&266 boost:: tuples::get<11>(zip_it_12_copy.get_iterator_tuple()) == ve4.end() &&267 1 == boost:: tuples::get<0>(zip_it_12_dereferenced) &&268 12 == boost:: tuples::get<11>(zip_it_12_dereferenced) &&265 if( boost::fusion::get<11>(zip_it_12.get_iterator_tuple()) == ve4.begin() && 266 boost::fusion::get<11>(zip_it_12_copy.get_iterator_tuple()) == ve4.end() && 267 1 == boost::fusion::get<0>(zip_it_12_dereferenced) && 268 12 == boost::fusion::get<11>(zip_it_12_dereferenced) && 269 269 42 == *(li4.begin()) 270 270 ) 271 271 { … … 293 293 vect2[2] = 4.4; 294 294 295 295 boost::zip_iterator< 296 boost:: tuples::tuple<296 boost::fusion::tuple< 297 297 std::vector<double>::const_iterator, 298 298 std::vector<double>::const_iterator 299 299 > 300 300 > 301 301 zip_it_begin( 302 boost:: make_tuple(302 boost::fusion::make_tuple( 303 303 vect1.begin(), 304 304 vect2.begin() 305 305 ) 306 306 ); 307 307 308 308 boost::zip_iterator< 309 boost:: tuples::tuple<309 boost::fusion::tuple< 310 310 std::vector<double>::const_iterator, 311 311 std::vector<double>::const_iterator 312 312 > 313 313 > 314 314 zip_it_run( 315 boost:: make_tuple(315 boost::fusion::make_tuple( 316 316 vect1.begin(), 317 317 vect2.begin() 318 318 ) 319 319 ); 320 320 321 321 boost::zip_iterator< 322 boost:: tuples::tuple<322 boost::fusion::tuple< 323 323 std::vector<double>::const_iterator, 324 324 std::vector<double>::const_iterator 325 325 > 326 326 > 327 327 zip_it_end( 328 boost:: make_tuple(328 boost::fusion::make_tuple( 329 329 vect1.end(), 330 330 vect2.end() 331 331 ) 332 332 ); 333 333 334 334 if( zip_it_run == zip_it_begin && 335 42. == boost:: tuples::get<0>(*zip_it_run) &&336 2.2 == boost:: tuples::get<1>(*zip_it_run) &&337 43. == boost:: tuples::get<0>(*(++zip_it_run)) &&338 3.3 == boost:: tuples::get<1>(*zip_it_run) &&339 44. == boost:: tuples::get<0>(*(++zip_it_run)) &&340 4.4 == boost:: tuples::get<1>(*zip_it_run) &&335 42. == boost::fusion::get<0>(*zip_it_run) && 336 2.2 == boost::fusion::get<1>(*zip_it_run) && 337 43. == boost::fusion::get<0>(*(++zip_it_run)) && 338 3.3 == boost::fusion::get<1>(*zip_it_run) && 339 44. == boost::fusion::get<0>(*(++zip_it_run)) && 340 4.4 == boost::fusion::get<1>(*zip_it_run) && 341 341 zip_it_end == ++zip_it_run 342 342 ) 343 343 { … … 361 361 362 362 if( zip_it_run == zip_it_end && 363 363 zip_it_end == zip_it_run-- && 364 44. == boost:: tuples::get<0>(*zip_it_run) &&365 4.4 == boost:: tuples::get<1>(*zip_it_run) &&366 43. == boost:: tuples::get<0>(*(--zip_it_run)) &&367 3.3 == boost:: tuples::get<1>(*zip_it_run) &&368 42. == boost:: tuples::get<0>(*(--zip_it_run)) &&369 2.2 == boost:: tuples::get<1>(*zip_it_run) &&364 44. == boost::fusion::get<0>(*zip_it_run) && 365 4.4 == boost::fusion::get<1>(*zip_it_run) && 366 43. == boost::fusion::get<0>(*(--zip_it_run)) && 367 3.3 == boost::fusion::get<1>(*zip_it_run) && 368 42. == boost::fusion::get<0>(*(--zip_it_run)) && 369 2.2 == boost::fusion::get<1>(*zip_it_run) && 370 370 zip_it_begin == zip_it_run 371 371 ) 372 372 { … … 389 389 << std::flush; 390 390 391 391 boost::zip_iterator< 392 boost:: tuples::tuple<392 boost::fusion::tuple< 393 393 std::vector<double>::const_iterator, 394 394 std::vector<double>::const_iterator 395 395 > … … 642 642 // Note: zip_it_run and zip_it_run_copy are both at 643 643 // begin plus one. 644 644 // 645 if( boost:: tuples::get<0>(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 &&646 boost:: tuples::get<1>(zip_it_run.get_iterator_tuple()) == vect2.begin() + 1645 if( boost::fusion::get<0>(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 && 646 boost::fusion::get<1>(zip_it_run.get_iterator_tuple()) == vect2.begin() + 1 647 647 ) 648 648 { 649 649 ++num_successful_tests; … … 664 664 std::cout << "Making zip iterators: " 665 665 << std::flush; 666 666 667 std::vector<boost:: tuples::tuple<double, double> >667 std::vector<boost::fusion::tuple<double, double> > 668 668 vect_of_tuples(3); 669 669 670 670 std::copy( 671 671 boost::make_zip_iterator( 672 boost:: make_tuple(672 boost::fusion::make_tuple( 673 673 vect1.begin(), 674 674 vect2.begin() 675 675 ) 676 676 ), 677 677 boost::make_zip_iterator( 678 boost:: make_tuple(678 boost::fusion::make_tuple( 679 679 vect1.end(), 680 680 vect2.end() 681 681 ) … … 683 683 vect_of_tuples.begin() 684 684 ); 685 685 686 if( 42. == boost:: tuples::get<0>(*vect_of_tuples.begin()) &&687 2.2 == boost:: tuples::get<1>(*vect_of_tuples.begin()) &&688 43. == boost:: tuples::get<0>(*(vect_of_tuples.begin() + 1)) &&689 3.3 == boost:: tuples::get<1>(*(vect_of_tuples.begin() + 1)) &&690 44. == boost:: tuples::get<0>(*(vect_of_tuples.begin() + 2)) &&691 4.4 == boost:: tuples::get<1>(*(vect_of_tuples.begin() + 2))686 if( 42. == boost::fusion::get<0>(*vect_of_tuples.begin()) && 687 2.2 == boost::fusion::get<1>(*vect_of_tuples.begin()) && 688 43. == boost::fusion::get<0>(*(vect_of_tuples.begin() + 1)) && 689 3.3 == boost::fusion::get<1>(*(vect_of_tuples.begin() + 1)) && 690 44. == boost::fusion::get<0>(*(vect_of_tuples.begin() + 2)) && 691 4.4 == boost::fusion::get<1>(*(vect_of_tuples.begin() + 2)) 692 692 ) 693 693 { 694 694 ++num_successful_tests; … … 710 710 << std::flush; 711 711 712 712 boost::zip_iterator< 713 boost:: tuples::tuple<713 boost::fusion::tuple< 714 714 std::set<int>::const_iterator, 715 715 std::vector<double>::const_iterator 716 716 > 717 717 > 718 718 zip_it_const( 719 boost:: make_tuple(719 boost::fusion::make_tuple( 720 720 intset.begin(), 721 721 vect2.begin() 722 722 ) 723 723 ); 724 724 // 725 725 boost::zip_iterator< 726 boost:: tuples::tuple<726 boost::fusion::tuple< 727 727 std::set<int>::iterator, 728 728 std::vector<double>::const_iterator 729 729 > 730 730 > 731 731 zip_it_half_const( 732 boost:: make_tuple(732 boost::fusion::make_tuple( 733 733 intset.begin(), 734 734 vect2.begin() 735 735 ) 736 736 ); 737 737 // 738 738 boost::zip_iterator< 739 boost:: tuples::tuple<739 boost::fusion::tuple< 740 740 std::set<int>::iterator, 741 741 std::vector<double>::iterator 742 742 > 743 743 > 744 744 zip_it_non_const( 745 boost:: make_tuple(745 boost::fusion::make_tuple( 746 746 intset.begin(), 747 747 vect2.begin() 748 748 ) … … 753 753 ++zip_it_const; 754 754 // zip_it_non_const = ++zip_it_const; // Error: can't convert from const to non-const 755 755 756 if( 54 == boost:: tuples::get<0>(*zip_it_const) &&757 4.4 == boost:: tuples::get<1>(*zip_it_const) &&758 53 == boost:: tuples::get<0>(*zip_it_half_const) &&759 3.3 == boost:: tuples::get<1>(*zip_it_half_const)756 if( 54 == boost::fusion::get<0>(*zip_it_const) && 757 4.4 == boost::fusion::get<1>(*zip_it_const) && 758 53 == boost::fusion::get<0>(*zip_it_half_const) && 759 3.3 == boost::fusion::get<1>(*zip_it_half_const) 760 760 ) 761 761 { 762 762 ++num_successful_tests; … … 794 794 // traversal. 795 795 // 796 796 typedef boost::zip_iterator< 797 boost:: tuples::tuple<797 boost::fusion::tuple< 798 798 std::vector<double>::const_iterator, 799 799 std::vector<double>::const_iterator 800 800 >