1[/============================================================================== 2 Copyright (C) 2001-2011 Joel de Guzman 3 Copyright (C) 2006 Dan Marsden 4 Copyright (C) 2010 Christopher Schmidt 5 6 Use, modification and distribution is subject to the Boost Software 7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 http://www.boost.org/LICENSE_1_0.txt) 9===============================================================================/] 10[section Algorithm] 11 12[heading Lazy Evaluation] 13 14Unlike __mpl__, Fusion algorithms are lazy[footnote Except for some 15special cases such as __for_each__ and __copy__ which are inherently 16imperative algorithms.] and non sequence-type preserving [footnote What 17does that mean? It means that when you operate on a sequence through a 18Fusion algorithm that returns a sequence, the sequence returned may not 19be of the same class as the original]. This is by design. Runtime 20efficiency is given a high priority. Like __mpl__, and unlike __stl__, 21fusion algorithms are mostly functional in nature such that algorithms 22are non mutating (no side effects). However, due to the high cost of 23returning full sequences such as vectors and lists, /Views/ are returned 24from Fusion algorithms instead. For example, the __transform__ algorithm 25does not actually return a transformed version of the original sequence. 26__transform__ returns a __transform_view__. This view holds a reference 27to the original sequence plus the transform function. Iteration over the 28__transform_view__ will apply the transform function over the sequence 29elements on demand. This /lazy/ evaluation scheme allows us to chain as 30many algorithms as we want without incurring a high runtime penalty. 31 32[heading Sequence Extension] 33 34The /lazy/ evaluation scheme where __algorithms__ return __views__ also 35allows operations such as __push_back__ to be totally generic. In Fusion, 36__push_back__ is actually a generic algorithm that works on all sequences. 37Given an input sequence `s` and a value `x`, Fusion's __push_back__ 38algorithm simply returns a __joint_view__: a view that holds a reference to 39the original sequence `s` and the value `x`. Functions that were once 40sequence specific and need to be implemented N times over N different 41sequences are now implemented only once. That is to say that Fusion 42sequences are cheaply extensible. 43 44To regain the original sequence, __conversion__ functions are provided. You 45may use one of the __conversion__ functions to convert back to the original 46sequence type. 47 48[heading Header] 49 50 #include <boost/fusion/algorithm.hpp> 51 #include <boost/fusion/include/algorithm.hpp> 52 53[section Auxiliary] 54 55The auxiliary algorithms provide the utility algorithms for sequences. 56 57[heading Header] 58 59 #include <boost/fusion/algorithm/auxiliary.hpp> 60 #include <boost/fusion/include/auxiliary.hpp> 61 62[section Functions] 63 64[section copy] 65 66[heading Description] 67Copy a sequence `src` to a sequence `dest`. 68It is also used to convert sequence into other. 69 70[heading Synopsis] 71 template <typename Seq1, typename Seq2> 72 typename __result_of_copy__<Seq1, Seq2>::type copy(Seq1 const& src, Seq2& dest); 73 74[table Parameters 75 [[Parameter][Requirement][Description]] 76 [[`src`][A model of __forward_sequence__, all elements contained in the `src` sequence should be convertible into the element contained in the `dest` sequence.][Operation's argument]] 77 [[`dest`][A model of __forward_sequence__, `e2 = e1` is valid expression for each pair of elements `e1` of `src` and `e2` of `dest`.][Operation's argument]] 78] 79 80[heading Expression Semantics] 81 __copy__(src, dest); 82 83[*Return type]: `void` 84 85[*Semantics]: `e2 = e1` for each element `e1` in `src` and `e2` in `dest`. 86 87[heading Complexity] 88Linear, exactly `__result_of_size__<Sequence>::value`. 89 90[heading Header] 91 92 #include <boost/fusion/algorithm/auxiliary/copy.hpp> 93 #include <boost/fusion/include/copy.hpp> 94 95[heading Example] 96 __vector__<int,int> vec(1,2); 97 __list__<int,int> ls; 98 __copy__(vec, ls); 99 assert(ls == __make_list__(1,2)); 100 101[endsect] 102 103[section move] 104 105[heading Description] 106move a sequence `src` to a sequence `dest`. 107It is also used to convert sequence into other. 108 109[heading Synopsis] 110 template <typename Seq1, typename Seq2> 111 typename __result_of_move__<Seq1, Seq2>::type move(Seq1&& src, Seq2& dest); 112 113[table Parameters 114 [[Parameter][Requirement][Description]] 115 [[`src`][A model of __forward_sequence__, all elements contained in the `src` sequence should be convertible into the element contained in the `dest` sequence.][Operation's argument]] 116 [[`dest`][A model of __forward_sequence__, `e2 = std::move(e1)` is valid expression for each pair of elements `e1` of `src` and `e2` of `dest`.][Operation's argument]] 117] 118 119[heading Expression Semantics] 120 __move__(src, dest); 121 122[*Return type]: `void` 123 124[*Semantics]: `e2 = std::move(e1)` for each element `e1` in `src` and `e2` in `dest`. 125 126[heading Complexity] 127Linear, exactly `__result_of_size__<Sequence>::value`. 128 129[heading Header] 130 131 #include <boost/fusion/algorithm/auxiliary/move.hpp> 132 #include <boost/fusion/include/move.hpp> 133 134[heading Example] 135 __vector__<int,int> vec(1,2); 136 __list__<int,int> ls; 137 __move__(std::move(vec), ls); 138 assert(ls == __make_list__(1,2)); 139 140[endsect] 141 142[endsect] 143 144[section Metafunctions] 145 146[section copy] 147 148[heading Description] 149A metafunction returning the result type of applying __copy__, which is always `void`. 150 151[heading Synopsis] 152 template <typename Seq1, typename Seq2> 153 struct copy 154 { 155 typedef void type; 156 }; 157 158[table Parameters 159 [[Parameter] [Requirement] [Description]] 160 [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]] 161 [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]] 162] 163 164[heading Expression Semantics] 165 result_of::copy<Seq1, Seq2>::type 166 167[*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence. 168Otherwise, none. 169 170[*Semantics]: Returns the return type of __copy__ for 2 sequences of types `Seq1` and `Seq2`. 171 172[heading Complexity] 173Constant. 174 175[heading Header] 176 177 #include <boost/fusion/algorithm/auxiliary/copy.hpp> 178 #include <boost/fusion/include/copy.hpp> 179 180[endsect] 181 182[section move] 183 184[heading Description] 185A metafunction returning the result type of applying __move__, which is always `void`. 186 187[heading Synopsis] 188 template <typename Seq1, typename Seq2> 189 struct move 190 { 191 typedef void type; 192 }; 193 194[table Parameters 195 [[Parameter] [Requirement] [Description]] 196 [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]] 197 [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]] 198] 199 200[heading Expression Semantics] 201 result_of::move<Seq1, Seq2>::type 202 203[*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence. 204Otherwise, none. 205 206[*Semantics]: Returns the return type of __move__ for 2 sequences of types `Seq1` and `Seq2`. 207 208[heading Complexity] 209Constant. 210 211[heading Header] 212 213 #include <boost/fusion/algorithm/auxiliary/move.hpp> 214 #include <boost/fusion/include/move.hpp> 215 216[endsect] 217 218[endsect] 219 220[endsect] 221 222 223[section Iteration] 224 225The iteration algorithms provide the fundamental algorithms for traversing 226a sequence repeatedly applying an operation to its elements. 227 228[heading Header] 229 230 #include <boost/fusion/algorithm/iteration.hpp> 231 #include <boost/fusion/include/iteration.hpp> 232 233[section Functions] 234 235[template fold_desc[name result_of_name arg_desc seq_concept arg_id arg_type_id invoke_desc semantics_elements_desc example_arg_transform example_result I0 I1 IN] 236[heading Description] 237For a sequence `seq`, initial state `initial_state`, and binary function object 238or function pointer `f`, [^[name]] returns the result of the repeated application of 239binary `f` to the result of the previous `f` invocation (`inital_state` if it is 240the first call) and [arg_desc] of `seq`. 241 242[def name_macro [name]] 243[def result_of_name_macro [result_of_name]] 244[heading Synopsis] 245 template< 246 typename Sequence, 247 typename State, 248 typename F 249 > 250 typename result_of_name_macro<Sequence, State const, F>::type name_macro( 251 Sequence& seq, State const& initial_state, F f); 252 253 template< 254 typename Sequence, 255 typename State, 256 typename F 257 > 258 typename result_of_name_macro<Sequence const, State const, F>::type name_macro( 259 Sequence const& seq, State const& initial_state, F f); 260 261 template< 262 typename Sequence, 263 typename State, 264 typename F 265 > 266 typename result_of_name_macro<Sequence, State, F>::type name_macro( 267 Sequence& seq, State& initial_state, F f); 268 269 template< 270 typename Sequence, 271 typename State, 272 typename F 273 > 274 typename result_of_name_macro<Sequence const, State, F>::type name_macro( 275 Sequence const& seq, State& initial_state, F f); 276 277[def seq_concept_macro [seq_concept]] 278[def arg_type_id_macro [arg_type_id]] 279[def arg_id_macro [arg_id]] 280[def invoke_desc_macro [invoke_desc]] 281[table Parameters 282 [[Parameter][Requirement][Description]] 283 [[`seq`][A model of seq_concept_macro][Operation's argument]] 284 [[`initial_state`][Any type][Initial state]] 285 [[`f`][`f(s,arg_id_macro)` with return type `__boost_result_of_call__<F(S,arg_type_id_macro)>::type` for current state `s` of type `S`, and for each invoke_desc_macro][Operation's argument]] 286] 287 288[heading Expression Semantics] 289 name_macro(seq, initial_state, f); 290 291[*Return type]: Any type 292 293[*Semantics]: Equivalent to [^f(... f(f(initial_state,[arg_id][I0]),[arg_id][I1]) ...[arg_id][IN])] where [^[arg_id]1 ...[arg_id]N] are [semantics_elements_desc]. 294 295[heading Complexity] 296Linear, exactly `__result_of_size__<Sequence>::value` applications of `f`. 297 298[heading Header] 299 300 #include <boost/fusion/algorithm/iteration/name_macro.hpp> 301 #include <boost/fusion/include/name_macro.hpp> 302 303[def example_result_macro [example_result]] 304[def example_arg_transform_macro [example_arg_transform]] 305[heading Example] 306 struct make_string 307 { 308 typedef std::string result_type; 309 310 template<typename T> 311 std::string operator()(const std::string& str, const T& t) const 312 { 313 return str + boost::lexical_cast<std::string>(example_arg_transform_macro); 314 } 315 }; 316 ... 317 const __vector__<int,int> vec(1,2); 318 assert(name_macro(vec,std::string(""), make_string()) == example_result_macro); 319] 320 321[section fold] 322[fold_desc fold..__result_of_fold__..each element..__forward_sequence__..e..E..element `e` of type `E` in `seq`..the consecutive elements of `seq`..t.."12"..1..2..N] 323[endsect] 324 325[section reverse_fold] 326[fold_desc reverse_fold..__result_of_reverse_fold__..each element..__bidirectional_sequence__..e..E..element `e` of type `E` in `seq`..the consecutive elements of `seq`..t.."21"..N..N-1..1] 327[endsect] 328 329[section iter_fold] 330[fold_desc iter_fold..__result_of_iter_fold__..iterators on each element..__forward_sequence__..it..It..iterator `it` of type `It` on an element of `seq`..consecutive iterators on the elements of `seq`..__deref__(t).."12"..1..2..N] 331[endsect] 332 333[section reverse_iter_fold] 334[fold_desc reverse_iter_fold..__result_of_reverse_iter_fold__..iterators on each element..__bidirectional_sequence__..it..It..iterator `it` of type `It` on an element of `seq`..consecutive iterators on the elements of `seq`..__deref__(t).."21"..N..N-1..1] 335[endsect] 336 337[section accumulate] 338[fold_desc accumulate..__result_of_accumulate__..each element..__forward_sequence__..e..E..element `e` of type `E` in `seq`..the consecutive elements of `seq`..t.."12"..1..2..N] 339[endsect] 340 341[section for_each] 342 343[heading Description] 344Applies a unary function object to each element of a sequence. 345 346[heading Synopsis] 347 template< 348 typename Sequence, 349 typename F 350 > 351 typename __result_of_for_each__<Sequence, F>::type for_each( 352 Sequence& seq, F f); 353 354[table Parameters 355 [[Parameter][Requirement][Description]] 356 [[`seq`][A model of __forward_sequence__, `f(e)` must be a valid expression for each element `e` in `seq`][Operation's argument]] 357 [[`f`][A unary __reg_callable_obj__][Operation's argument]] 358] 359 360[heading Expression Semantics] 361 __for_each__(seq, f); 362 363[*Return type]: `void` 364 365[*Semantics]: Calls `f(e)` for each element `e` in `seq`. 366 367[heading Complexity] 368Linear, exactly `__result_of_size__<Sequence>::value` applications of `f`. 369 370[heading Header] 371 372 #include <boost/fusion/algorithm/iteration/for_each.hpp> 373 #include <boost/fusion/include/for_each.hpp> 374 375[heading Example] 376 struct increment 377 { 378 template<typename T> 379 void operator()(T& t) const 380 { 381 ++t; 382 } 383 }; 384 ... 385 __vector__<int,int> vec(1,2); 386 __for_each__(vec, increment()); 387 assert(vec == __make_vector__(2,3)); 388 389[endsect] 390 391[endsect] 392 393[section Metafunctions] 394 395[template meta_fold_desc[name name_func seq_concept arg_id arg_type_id invoke_meta_desc] 396[heading Description] 397Returns the result type of [name_func]. 398 399[def name_macro [name]] 400[heading Synopsis] 401 template< 402 typename Sequence, 403 typename State, 404 typename F> 405 struct name_macro 406 { 407 typedef __unspecified__ type; 408 }; 409 410[def seq_concept_macro [seq_concept]] 411[def arg_type_id_macro [arg_type_id]] 412[def arg_id_macro [arg_id]] 413[def invoke_meta_desc_macro [invoke_meta_desc]] 414[table Parameters 415 [[Parameter] [Requirement] [Description]] 416 [[`Sequence`] [A model of seq_concept_macro] [The sequence to iterate]] 417 [[`State`] [Any type] [The initial state for the first application of `F`]] 418 [[`F`] [`__boost_result_of_call__<F(S,arg_type_id_macro)>::type` is the return type of `f(s,arg_id_macro)` with current state `s` of type `S`, and an invoke_meta_desc_macro][The operation to be applied on traversal]] 419] 420 421[heading Expression Semantics] 422 name_macro<Sequence, State, F>::type 423 424[*Return type]: Any type 425 426[*Semantics]: Returns the result of applying [name_func] to a sequence of type 427`Sequence`, with an initial state of type `State` and binary function object or 428function pointer of type `F`. 429 430[heading Complexity] 431Linear, exactly `__result_of_size__<Sequence>::value` applications of `F`. 432 433[heading Header] 434 435 #include <boost/fusion/algorithm/iteration/name_macro.hpp> 436 #include <boost/fusion/include/name_macro.hpp> 437] 438 439[section fold] 440[meta_fold_desc fold..__fold__..__forward_sequence__..e..E..element `e` of type `E` in `seq`] 441[endsect] 442 443[section reverse_fold] 444[meta_fold_desc reverse_fold..__reverse_fold__..__bidirectional_sequence__..e..E..element `e` of type `E` in `seq`] 445[endsect] 446 447[section iter_fold] 448[meta_fold_desc iter_fold..__iter_fold__..__forward_sequence__..it..It..iterator `it` of type `It` on an element of `seq`] 449[endsect] 450 451[section reverse_iter_fold] 452[meta_fold_desc reverse_iter_fold..__reverse_iter_fold__..__bidirectional_sequence__..it..It..iterator `it` of type `It` on an element of `seq`] 453[endsect] 454 455[section accumulate] 456[meta_fold_desc accumulate..__accumulate__..__forward_sequence__..e..E..element `e` of type `E` in `seq`] 457[endsect] 458 459[section for_each] 460 461[heading Description] 462A metafunction returning the result type of applying __for_each__ to a sequence. The 463return type of __for_each__ is always `void`. 464 465[heading Synopsis] 466 template< 467 typename Sequence, 468 typename F 469 > 470 struct for_each 471 { 472 typedef void type; 473 }; 474 475[table Parameters 476 [[Parameter] [Requirement] [Description]] 477 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 478 [[`F`] [Any type] [Operation's argument]] 479] 480 481[heading Expression Semantics] 482 __result_of_for_each__<Sequence, F>::type 483 484[*Return type]: `void`. 485 486[*Semantics]: Returns the return type of __for_each__ for a sequence of type `Sequence` and a unary function object `F`. 487The return type is always `void`. 488 489[heading Complexity] 490Constant. 491 492[heading Header] 493 494 #include <boost/fusion/algorithm/iteration/for_each.hpp> 495 #include <boost/fusion/include/for_each.hpp> 496 497[endsect] 498 499[endsect] 500 501[endsect] 502 503[section Query] 504The query algorithms provide support for searching and analyzing sequences. 505 506[heading Header] 507 508 #include <boost/fusion/algorithm/query.hpp> 509 #include <boost/fusion/include/query.hpp> 510 511[section Functions] 512 513[section any] 514 515[heading Description] 516For a sequence `seq` and unary function object `f`, `any` returns true if `f` returns true for at least one element of `seq`. 517 518[heading Synopsis] 519 template< 520 typename Sequence, 521 typename F 522 > 523 typename __result_of_any__<Sequence,F>::type any( 524 Sequence const& seq, F f); 525 526[table Parameters 527 [[Parameter][Requirement][Description]] 528 [[`seq`][A model of __forward_sequence__, `f(e)` must be a valid expression, convertible to `bool`, for each element `e` in `seq`][The sequence to search]] 529 [[`f`][A unary function object][The search predicate]] 530] 531 532[heading Expression semantics] 533 __any__(seq, f); 534 535[*Return type]: `bool` 536 537[*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for some element `e` in `seq`. 538 539[heading Complexity] 540Linear. At most `__result_of_size__<Sequence>::value` comparisons. 541 542[heading Header] 543 544 #include <boost/fusion/algorithm/query/any.hpp> 545 #include <boost/fusion/include/any.hpp> 546 547[heading Example] 548 struct odd 549 { 550 template<typename T> 551 bool operator()(T t) const 552 { 553 return t % 2; 554 } 555 }; 556 ... 557 assert(__any__(__make_vector__(1,2), odd())); 558 assert(!__any__(__make_vector__(2,4), odd())); 559 560[endsect] 561 562[section all] 563 564[heading Description] 565For a sequence `seq` and unary function object `f`, `all` returns true if `f` returns true for every element of `seq`. 566 567[heading Synopsis] 568 template< 569 typename Sequence, 570 typename F 571 > 572 typename __result_of_all__<Sequence,F>::type all( 573 Sequence const& seq, F f); 574 575[table Parameters 576 [[Parameter][Requirement][Description]] 577 [[`seq`][A model of __forward_sequence__, `f(e)` is a valid expression, convertible to `bool`, for every element `e` in `seq`][The sequence to search]] 578 [[`f`][A unary function object][The search predicate]] 579] 580 581[heading Expression Semantics] 582 __all__(seq, f); 583 584[*Return type]: `bool` 585 586[*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for every element `e` in `seq`. 587 588[heading Complexity] 589Linear. At most `__result_of_size__<Sequence>::value` comparisons. 590 591[heading Header] 592 593 #include <boost/fusion/algorithm/query/all.hpp> 594 #include <boost/fusion/include/all.hpp> 595 596[heading Example] 597 struct odd 598 { 599 template<typename T> 600 bool operator()(T t) const 601 { 602 return t % 2; 603 } 604 }; 605 ... 606 assert(__all__(__make_vector__(1,3), odd())); 607 assert(!__all__(__make_vector__(1,2), odd())); 608 609[endsect] 610 611[section none] 612 613[heading Description] 614For a sequence `seq` and unary function object `f`, `none` returns true if `f` returns false for every element of `seq`. 615 616[heading Synopsis] 617 template< 618 typename Sequence, 619 typename F 620 > 621 typename __result_of_none__<Sequence,F>::type none( 622 Sequence const& seq, F f); 623 624[table Parameters 625 [[Parameter][Requirement][Description]] 626 [[`seq`][A model of __forward_sequence__, `f(e)` is a valid expression, convertible to `bool`, for every element `e` in `seq`][The sequence to search]] 627 [[`f`][A unary function object][The search predicate]] 628] 629 630[heading Expression Semantics] 631 __none__(seq, f); 632 633[*Return type]: `bool` 634 635[*Semantics]: Returns true if and only if `f(e)` evaluates to `false` for every element `e` in `seq`. Result equivalent to `!any(seq, f)`. 636 637[heading Complexity] 638Linear. At most `__result_of_size__<Sequence>::value` comparisons. 639 640[heading Header] 641 642 #include <boost/fusion/algorithm/query/none.hpp> 643 #include <boost/fusion/include/none.hpp> 644 645[heading Example] 646 struct odd 647 { 648 template<typename T> 649 bool operator()(T t) const 650 { 651 return t % 2; 652 } 653 }; 654 ... 655 assert(__none__(__make_vector__(2,4), odd())); 656 assert(!__none__(__make_vector__(1,2), odd())); 657 658[endsect] 659 660[section find] 661 662[heading Description] 663Finds the first element of a given type within a sequence. 664 665[heading Synopsis] 666 template< 667 typename T, 668 typename Sequence 669 > 670 typename __result_of_find__<Sequence const, T>::type find(Sequence const& seq); 671 672 template< 673 typename T, 674 typename Sequence 675 > 676 typename __result_of_find__<Sequence, T>::type find(Sequence& seq); 677 678[table Parameters 679 [[Parameter][Requirement][Description]] 680 [[`seq`][A model of __forward_sequence__][The sequence to search]] 681 [[`T`][Any type][The type to search for]] 682] 683 684[heading Expression Semantics] 685 __find__<T>(seq) 686 687[*Return type]: A model of the same iterator category as the iterators of `seq`. 688 689[*Semantics]: Returns an iterator to the first element of `seq` of type `T`, or `__end__(seq)` if there is no such element. 690Equivalent to `__find_if__<boost::is_same<_, T> >(seq)` 691 692[heading Complexity] 693Linear. At most `__result_of_size__<Sequence>::value` comparisons. 694 695[heading Header] 696 697 #include <boost/fusion/algorithm/query/find.hpp> 698 #include <boost/fusion/include/find.hpp> 699 700[heading Example] 701 const __vector__<char,int> vec('a','0'); 702 assert(*__find__<int>(vec) == '0'); 703 assert(__find__<double>(vec) == __end__(vec)); 704 705[endsect] 706 707[section find_if] 708 709[heading Description] 710Finds the first element within a sequence with a type for which a given __mpl_lambda_expression__ evaluates to 711`boost::mpl::true_`. 712 713[heading Synopsis] 714 template< 715 typename F, 716 typename Sequence 717 > 718 typename __result_of_find_if__<Sequence const, F>::type find_if(Sequence const& seq); 719 720 template< 721 typename F, 722 typename Sequence 723 > 724 typename __result_of_find_if__<Sequence, F>::type find_if(Sequence& seq); 725 726[table Parameters 727 [[Parameter][Requirement][Description]] 728 [[`seq`][A model of __forward_sequence__][The sequence to search]] 729 [[`F`][A unary __mpl_lambda_expression__][The search predicate]] 730] 731 732[heading Expression Semantics] 733 __find_if__<F>(seq) 734 735[*Return type]: An iterator of the same iterator category as the iterators of `seq`. 736 737[*Semantics]: Returns the first element of `seq` for which __mpl_lambda_expression__ `F` evaluates to `boost::mpl::true_`, 738or `__end__(seq)` if there is no such element. 739 740[heading Complexity] 741Linear. At most `__result_of_size__<Sequence>::value` comparisons. 742 743[heading Header] 744 745 #include <boost/fusion/algorithm/query/find_if.hpp> 746 #include <boost/fusion/include/find_if.hpp> 747 748[heading Example] 749 const __vector__<double,int> vec(1.0,2); 750 assert(*__find_if__<is_integral<mpl::_> >(vec) == 2); 751 assert(__find_if__<is_class<mpl::_> >(vec) == __end__(vec)); 752 753[endsect] 754 755[section count] 756 757[heading Description] 758Returns the number of elements of a given type within a sequence. 759 760[heading Synopsis] 761 template< 762 typename Sequence, 763 typename T 764 > 765 typename __result_of_count__<Sequence, T>::type count( 766 Sequence const& seq, T const& t); 767 768[table Parameters 769 [[Parameter][Requirement][Description]] 770 [[`seq`][A model of __forward_sequence__, `e == t` must be a valid expression, convertible to `bool`, for each element `e` in `seq`][The sequence to search]] 771 [[`T`][Any type][The type to count]] 772] 773 774[heading Expression Semantics] 775 __count__(seq, t); 776 777[*Return type]: `int` 778 779[*Semantics]: Returns the number of elements of type `T` and equal to `t` in `seq`. 780 781[heading Complexity] 782Linear. At most `__result_of_size__<Sequence>::value` comparisons. 783 784[heading Header] 785 786 #include <boost/fusion/algorithm/query/count.hpp> 787 #include <boost/fusion/include/count.hpp> 788 789[heading Example] 790 const __vector__<double,int,int> vec(1.0,2,3); 791 assert(__count__(vec,2) == 1); 792 793[endsect] 794 795[section count_if] 796 797[heading Description] 798Returns the number of elements within a sequence with a type for which a given unary function object evaluates to 799`true`. 800 801[heading Synopsis] 802 template< 803 typename Sequence, 804 typename F 805 > 806 typename __result_of_count_if__<Sequence, F>::type count_if( 807 Sequence const& seq, F f); 808 809[table Parameters 810 [[Parameter][Requirement][Description]] 811 [[`seq`][A model of __forward_sequence__, `f(e)` is a valid expression, convertible to `bool`, for each element `e` in `seq`][The sequence to search]] 812 [[`f`][A unary function object][The search predicate]] 813] 814 815[heading Expression Semantics] 816 __count_if__(seq, f) 817 818[*Return type]: `int` 819 820[*Semantics]: Returns the number of elements in `seq` where `f` evaluates to `true`. 821 822[heading Complexity] 823Linear. At most `__result_of_size__<Sequence>::value` comparisons. 824 825[heading Header] 826 827 #include <boost/fusion/algorithm/query/count_if.hpp> 828 #include <boost/fusion/include/count_if.hpp> 829 830[heading Example] 831 const __vector__<int,int,int> vec(1,2,3); 832 assert(__count_if__(vec,odd()) == 2); 833 834[endsect] 835 836[endsect] 837 838[section Metafunctions] 839 840[section any] 841 842[heading Description] 843A metafunction returning the result type of __any__. 844 845[heading Synopsis] 846 template< 847 typename Sequence, 848 typename F 849 > 850 struct any 851 { 852 typedef bool type; 853 }; 854 855[table Parameters 856 [[Parameter] [Requirement] [Description]] 857 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 858 [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] 859] 860 861[heading Expression Semantics] 862 __result_of_any__<Sequence, F>::type 863 864[*Return type]: `bool`. 865 866[*Semantics]: Returns the return type of __any__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`. 867 868[heading Complexity] 869Constant. 870 871[heading Header] 872 873 #include <boost/fusion/algorithm/query/any.hpp> 874 #include <boost/fusion/include/any.hpp> 875 876[endsect] 877 878[section all] 879 880[heading Description] 881A metafunction returning the result type of __all__. 882 883[heading Synopsis] 884 template< 885 typename Sequence, 886 typename F 887 > 888 struct all 889 { 890 typedef bool type; 891 }; 892 893[table Parameters 894 [[Parameter] [Requirement] [Description]] 895 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 896 [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] 897] 898 899[heading Expression Semantics] 900 __result_of_all__<Sequence, F>::type 901 902[*Return type]: `bool`. 903 904[*Semantics]: Returns the return type of __all__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`. 905 906[heading Complexity] 907Constant. 908 909[heading Header] 910 911 #include <boost/fusion/algorithm/query/all.hpp> 912 #include <boost/fusion/include/all.hpp> 913 914[endsect] 915 916[section none] 917 918[heading Description] 919A metafunction returning the result type of __none__. 920 921[heading Synopsis] 922 template< 923 typename Sequence, 924 typename F 925 > 926 struct none 927 { 928 typedef bool type; 929 }; 930 931[table Parameters 932 [[Parameter] [Requirement] [Description]] 933 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 934 [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] 935] 936 937[heading Expression Semantics] 938 __result_of_none__<Sequence, F>::type 939 940[*Return type]: `bool`. 941 942[*Semantics]: Returns the return type of __none__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`. 943 944[heading Complexity] 945Constant. 946 947[heading Header] 948 949 #include <boost/fusion/algorithm/query/none.hpp> 950 #include <boost/fusion/include/none.hpp> 951 952[endsect] 953 954[section find] 955 956[heading Description] 957Returns the result type of __find__, given the sequence and search types. 958 959[heading Synopsis] 960 template< 961 typename Sequence, 962 typename T 963 > 964 struct find 965 { 966 typedef __unspecified__ type; 967 }; 968 969[table Parameters 970 [[Parameter] [Requirement] [Description]] 971 [[`Sequence`] [Model of __forward_sequence__] [Operation's argument]] 972 [[`T`] [Any type] [Operation's argument]] 973] 974 975[heading Expression Semantics] 976 __result_of_find__<Sequence, T>::type 977 978[*Return type]: A model of the same iterator category as the iterators of `Sequence`. 979 980[*Semantics]: Returns an iterator to the first element of type `T` in `Sequence`, or `__result_of_end__<Sequence>::type` if there is no such element. 981 982[heading Complexity] 983Linear, at most `__result_of_size__<Sequence>::value` comparisons. 984 985[heading Header] 986 987 #include <boost/fusion/algorithm/query/find.hpp> 988 #include <boost/fusion/include/find.hpp> 989 990[endsect] 991 992[section find_if] 993 994[heading Description] 995Returns the result type of __find_if__ given the sequence and predicate types. 996 997[heading Synopsis] 998 template< 999 typename Sequence, 1000 typename Pred 1001 > 1002 struct find_if 1003 { 1004 typedef __unspecified__ type; 1005 }; 1006 1007[table Parameters 1008 [[Parameter] [Requirement] [Description]] 1009 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 1010 [[`Pred`] [A model of __mpl_lambda_expression__] [Operation's arguments]] 1011] 1012 1013[heading Expression Semantics] 1014 __result_of_find_if__<Sequence, Pred>::type 1015 1016[*Return type]: A model of the same iterator category as the iterators of `Sequence`. 1017 1018[*Semantics]: Returns an iterator to the first element in `Sequence` for which `Pred` evaluates to true. Returns `__result_of_end__<Sequence>::type` if there is no such element. 1019 1020[heading Complexity] 1021Linear. At most `__result_of_size__<Sequence>::value` comparisons. 1022 1023[heading Header] 1024 1025 #include <boost/fusion/algorithm/query/find_if.hpp> 1026 #include <boost/fusion/include/find_if.hpp> 1027 1028[endsect] 1029 1030[section count] 1031 1032[heading Description] 1033A metafunction that returns the result type of `count` given the sequence and search types. 1034 1035[heading Synopsis] 1036 template< 1037 typename Sequence, 1038 typename T 1039 > 1040 struct count 1041 { 1042 typedef int type; 1043 }; 1044 1045[table Parameters 1046 [[Parameter] [Requirement] [heading Description]] 1047 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 1048 [[`T`] [Any type] [Operation's argument]] 1049] 1050 1051[heading Expression Semantics] 1052 __result_of_count__<T>::type 1053 1054[*Return type]: `int`. 1055 1056[*Semantics]: Returns the return type of __count__. The return type is always `int`. 1057 1058[heading Complexity] 1059Constant. 1060 1061[heading Header] 1062 1063 #include <boost/fusion/algorithm/query/count.hpp> 1064 #include <boost/fusion/include/count.hpp> 1065 1066[endsect] 1067 1068[section count_if] 1069 1070[heading Description] 1071A metafunction that returns the result type of `count_if` given the sequence and predicate types. 1072 1073[heading Synopsis] 1074 template< 1075 typename Sequence, 1076 typename Pred 1077 > 1078 struct count_if 1079 { 1080 typedef int type; 1081 }; 1082 1083[table Parameters 1084 [[Parameter] [Requirement] [Description]] 1085 [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] 1086 [[`Pred`] [A unary function object] [Operation's argument]] 1087] 1088 1089[heading Expression Semantics] 1090 __result_of_count_if__<Sequence, Pred>::type 1091 1092[*Return type]: `int`. 1093 1094[*Semantics]: Returns the return type of __count_if__. The return type is always `int`. 1095 1096[heading Complexity] 1097Constant. 1098 1099[heading Header] 1100 1101 #include <boost/fusion/algorithm/query/count_if.hpp> 1102 #include <boost/fusion/include/count_if.hpp> 1103 1104[endsect] 1105 1106[endsect] 1107 1108[endsect] 1109 1110[section Transformation] 1111The transformation algorithms create new sequences out of existing sequences by performing some sort of transformation. In reality the new sequences are views onto the data in the original sequences. 1112 1113[note As the transformation algorithms return views onto their input arguments, 1114it is important that the lifetime of the input arguments is greater than the 1115period during which you wish to use the results.] 1116 1117[heading Header] 1118 1119 #include <boost/fusion/algorithm/transformation.hpp> 1120 #include <boost/fusion/include/transformation.hpp> 1121 1122[section Functions] 1123 1124[section filter] 1125 1126[heading Description] 1127For a given sequence, filter returns a new sequences containing only the elements of a specified type. 1128 1129[heading Synopsis] 1130 template< 1131 typename T, 1132 typename Sequence 1133 > 1134 typename __result_of_filter__<Sequence const, T>::type filter(Sequence const& seq); 1135 1136[table Parameters 1137 [[Parameter][Requirement][Description]] 1138 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1139 [[`T`][Any type][The type to retain]] 1140] 1141 1142[heading Expression Semantics] 1143 __filter__<T>(seq); 1144 1145[*Return type]: 1146 1147* A model of __forward_sequence__. 1148* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1149 1150[*Semantics]: Returns a sequence containing all the elements of `seq` of type `T`. 1151Equivalent to `__filter_if__<boost::same_type<_, T> >(seq)`. 1152 1153[heading Complexity] 1154Constant. Returns a view which is lazily evaluated. 1155 1156[heading Header] 1157 1158 #include <boost/fusion/algorithm/transformation/filter.hpp> 1159 #include <boost/fusion/include/filter.hpp> 1160 1161[heading Example] 1162 const __vector__<int,int,long,long> vec(1,2,3,4); 1163 assert(__filter__<int>(vec) == __make_vector__(1,2)); 1164 1165[endsect] 1166 1167[section filter_if] 1168 1169[heading Description] 1170For a given sequence, __filter_if__ returns a new sequences containing 1171only the elements with types for which a given __mpl_lambda_expression__ evaluates to `boost::mpl::true_`. 1172 1173[heading Synopsis] 1174 template< 1175 typename Pred, 1176 typename Sequence 1177 > 1178 typename __result_of_filter_if__<Sequence const, Pred>::type filter_if(Sequence const& seq); 1179 1180[table Parameters 1181 [[Parameter][Requirement][Description]] 1182 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1183 [[`Pred`][A unary __mpl_lambda_expression__][The predicate to filter by]] 1184] 1185 1186[heading Expression Semantics] 1187 __filter_if__<Pred>(seq); 1188 1189[*Return type]: 1190 1191* A model of __forward_sequence__. 1192* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1193 1194[*Semantics]: Returns a sequence containing all the elements of `seq` with types for which `Pred` evaluates 1195to `boost::mpl::true_`. The order of the retained elements is the same as in the original sequence. 1196 1197[heading Complexity] 1198Constant. Returns a view which is lazily evaluated. 1199 1200[heading Header] 1201 1202 #include <boost/fusion/algorithm/transformation/filter_if.hpp> 1203 #include <boost/fusion/include/filter_if.hpp> 1204 1205[heading Example] 1206 const __vector__<int,int,double,double> vec(1,2,3.0,4.0); 1207 assert(__filter_if__<is_integral<mpl::_> >(vec) == __make_vector__(1,2)); 1208 1209[endsect] 1210 1211[section transform] 1212 1213[heading Description] 1214For a sequence `seq` and function object or function pointer `f`, `transform` returns a new sequence 1215with elements created by applying `f(e)` to each element of `e` of `seq`. 1216 1217[heading Unary version synopsis] 1218 template< 1219 typename Sequence, 1220 typename F 1221 > 1222 typename __result_of_transform__<Sequence const, F>::type transform( 1223 Sequence const& seq, F f); 1224 1225[table Parameters 1226 [[Parameter][Requirement][Description]] 1227 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1228 [[`f`][`f(e)` is a valid expression for each element `e` of `seq`. `__boost_result_of_call__<F(E)>::type` is the return type of `f` when called with a value of each element type `E`.][Transformation function]] 1229] 1230 1231[heading Expression Semantics] 1232 __transform__(seq, f); 1233 1234[*Return type]: A model of __forward_sequence__ 1235 1236[*Semantics]: Returns a new sequence, containing the return values of `f(e)` for each element `e` within `seq`. 1237 1238[heading Binary version synopsis] 1239 template< 1240 typename Sequence1, 1241 typename Sequence2, 1242 typename F 1243 > 1244 typename __result_of_transform__<Sequence1 const, Sequence2 const, F>::type transform( 1245 Sequence1 const& seq1, Sequence2 const& seq2, F f); 1246 1247[table Parameters 1248 [[Parameter][Requirement][Description]] 1249 [[`seq1`][A model of __forward_sequence__][Operation's argument]] 1250 [[`seq2`][A model of __forward_sequence__][Operation's argument]] 1251 [[`f`][`f(e1,e2)` is a valid expression for each pair of elements `e1` of `seq1` and `e2` of `seq2`. `__boost_result_of_call__<F(E1,E2)>::type` is the return type of `f` when called with elements of type `E1` and `E2`][Transformation function]] 1252] 1253 1254[*Return type]: A model of __forward_sequence__. 1255 1256[*Semantics]: Returns a new sequence, containing the return values of `f(e1, e2)` for each pair of elements `e1` and `e2` within `seq1` and `seq2` respectively. 1257 1258[heading Complexity] 1259Constant. Returns a view which is lazily evaluated. 1260 1261[heading Header] 1262 1263 #include <boost/fusion/algorithm/transformation/transform.hpp> 1264 #include <boost/fusion/include/transform.hpp> 1265 1266[heading Example] 1267 struct triple 1268 { 1269 typedef int result_type; 1270 1271 int operator()(int t) const 1272 { 1273 return t * 3; 1274 }; 1275 }; 1276 ... 1277 assert(__transform__(__make_vector__(1,2,3), triple()) == __make_vector__(3,6,9)); 1278 1279[endsect] 1280 1281[section replace] 1282 1283[heading Description] 1284Replaces each value within a sequence of a given type and value with a new value. 1285 1286[heading Synopsis] 1287 template< 1288 typename Sequence, 1289 typename T 1290 > 1291 typename __result_of_replace__<Sequence const, T>::type replace( 1292 Sequence const& seq, T const& old_value, T const& new_value); 1293 1294[table Parameters 1295 [[Parameter][Requirement][Description]] 1296 [[`seq`][A model of __forward_sequence__, `e == old_value` is a valid expression, convertible to `bool`, for each element `e` in `seq` with type convertible to `T`][Operation's argument]] 1297 [[`old_value`][Any type][Value to replace]] 1298 [[`new_value`][Any type][Replacement value]] 1299] 1300 1301[heading Expression Semantics] 1302 __replace__(seq, old_value, new_value); 1303 1304[*Return type]: A model of __forward_sequence__. 1305 1306[*Semantics]: Returns a new sequence with all the values of `seq` with `new_value` assigned to elements with the same type and equal to `old_value`. 1307 1308[heading Complexity] 1309Constant. Returns a view which is lazily evaluated. 1310 1311[heading Header] 1312 1313 #include <boost/fusion/algorithm/transformation/replace.hpp> 1314 #include <boost/fusion/include/replace.hpp> 1315 1316[heading Example] 1317 assert(__replace__(__make_vector__(1,2), 2, 3) == __make_vector__(1,3)); 1318 1319[endsect] 1320 1321[section replace_if] 1322 1323[heading Description] 1324Replaces each element of a given sequence for which an unary function object evaluates to `true` replaced with 1325a new value. 1326 1327[heading Synopsis] 1328 template< 1329 typename Sequence, 1330 typename F, 1331 typename T> 1332 typename __result_of_replace_if__<Sequence const, F, T>::type replace_if( 1333 Sequence const& seq, F f, T const& new_value); 1334 1335[table Parameters 1336 [[Parameter][Requirement][Description]] 1337 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1338 [[`f`][A function object for which `f(e)` is a valid expression, convertible to `bool`, for each element `e` in `seq`][Operation's argument]] 1339 [[`new_value`][Any type][Replacement value]] 1340] 1341 1342[heading Expression Semantics] 1343 __replace_if__(seq, f, new_value); 1344 1345[*Return type]: A model of __forward_sequence__. 1346 1347[*Semantics]: Returns a new sequence with all the elements of `seq`, 1348with `new_value` assigned to each element for which `f` evaluates to `true`. 1349 1350[heading Complexity] 1351Constant. Returns a view which is lazily evaluated. 1352 1353[heading Header] 1354 1355 #include <boost/fusion/algorithm/transformation/replace_if.hpp> 1356 #include <boost/fusion/include/replace_if.hpp> 1357 1358[heading Example] 1359 struct odd 1360 { 1361 template<typename T> 1362 bool operator()(T t) const 1363 { 1364 return t % 2; 1365 } 1366 }; 1367 ... 1368 assert(__replace_if__(__make_vector__(1,2), odd(), 3) == __make_vector__(3,2)); 1369 1370[endsect] 1371 1372[section remove] 1373 1374[heading Description] 1375Returns a new sequence, with all the elements of the original sequence, except those of a given type. 1376 1377[heading Synopsis] 1378 template< 1379 typename T, 1380 typename Sequence 1381 > 1382 typename __result_of_remove__<Sequence const, T>::type remove(Sequence const& seq); 1383 1384[table Parameters 1385 [[Parameter][Requirement][Description]] 1386 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1387 [[`T`][Any type][Type to remove]] 1388] 1389 1390[heading Expression Semantics] 1391 __remove__<T>(seq); 1392 1393[*Return type]: 1394 1395* A model of __forward_sequence__. 1396* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 1397 1398[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except 1399those of type `T`. Equivalent to `__remove_if__<boost::is_same<_,T> >(seq)`. 1400 1401[heading Complexity] 1402Constant. Returns a view which is lazily evaluated. 1403 1404[heading Header] 1405 1406 #include <boost/fusion/algorithm/transformation/remove.hpp> 1407 #include <boost/fusion/include/remove.hpp> 1408 1409[heading Example] 1410 const __vector__<int,double> vec(1,2.0); 1411 assert(__remove__<double>(vec) == __make_vector__(1)); 1412 1413[endsect] 1414 1415[section remove_if] 1416 1417[heading Description] 1418Returns a new sequence, containing all the elements of the original except those where a given unary 1419function object evaluates to `true`. 1420 1421[heading Synopsis] 1422 template< 1423 typename Pred, 1424 typename Sequence 1425 > 1426 typename __result_of_remove_if__<Sequence const, Pred>::type remove_if(Sequence const& seq); 1427 1428[table Parameters 1429 [[Parameter][Requirement][Description]] 1430 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1431 [[`Pred`][A model of unary __mpl_lambda_expression__][Removal predicate]] 1432] 1433 1434[heading Expression Semantics] 1435 __remove_if__<Pred>(seq); 1436 1437[*Return type]: 1438 1439* A model of __forward_sequence__. 1440* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1441 1442[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except 1443those elements with types for which `Pred` evaluates to `boost::mpl::true_`. 1444Equivalent to `__filter__<boost::mpl::not_<Pred> >(seq)`. 1445 1446[heading Complexity] 1447Constant. Returns a view which is lazily evaluated. 1448 1449[heading Header] 1450 1451 #include <boost/fusion/algorithm/transformation/remove_if.hpp> 1452 #include <boost/fusion/include/remove_if.hpp> 1453 1454[heading Example] 1455 const __vector__<int,double> vec(1,2.0); 1456 assert(__remove_if__<is_floating_point<mpl::_> >(vec) == __make_vector__(1)); 1457 1458[endsect] 1459 1460[section reverse] 1461 1462[heading Description] 1463Returns a new sequence with the elements of the original in reverse order. 1464 1465[heading Synopsis] 1466 template< 1467 typename Sequence 1468 > 1469 typename __result_of_reverse__<Sequence const>::type reverse(Sequence const& seq); 1470 1471[table Parameters 1472 [[Parameter][Requirement][Description]] 1473 [[`seq`][A model of __bidirectional_sequence__][Operation's argument]] 1474] 1475 1476[heading Expression Semantics] 1477 __reverse__(seq); 1478 1479[*Return type]: 1480 1481* A model of __bidirectional_sequence__ if `seq` is a __bidirectional_sequence__ 1482else, __random_access_sequence__ if `seq` is a __random_access_sequence__. 1483* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1484 1485[*Semantics]: Returns a new sequence containing all the elements of `seq` in reverse order. 1486 1487[heading Complexity] 1488Constant. Returns a view which is lazily evaluated. 1489 1490[heading Header] 1491 1492 #include <boost/fusion/algorithm/transformation/reverse.hpp> 1493 #include <boost/fusion/include/reverse.hpp> 1494 1495[heading Example] 1496 assert(__reverse__(__make_vector__(1,2,3)) == __make_vector__(3,2,1)); 1497 1498[endsect] 1499 1500[section clear] 1501 1502[heading Description] 1503__clear__ returns an empty sequence. 1504 1505[heading Synopsis] 1506 template< 1507 typename Sequence 1508 > 1509 typename __result_of_clear__<Sequence const>::type clear(Sequence const& seq); 1510 1511[table Parameters 1512 [[Parameter][Requirement][Description]] 1513 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1514] 1515 1516[heading Expression Semantics] 1517 __clear__(seq); 1518 1519[*Return type]: A model of __forward_sequence__. 1520 1521[*Expression Semantics]: Returns a sequence with no elements. 1522 1523[heading Complexity] 1524Constant. 1525 1526[heading Header] 1527 1528 #include <boost/fusion/algorithm/transformation/clear.hpp> 1529 #include <boost/fusion/include/clear.hpp> 1530 1531[heading Example] 1532 assert(__clear__(__make_vector__(1,2,3)) == __make_vector__()); 1533 1534[endsect] 1535 1536[section erase] 1537 1538[heading Description] 1539Returns a new sequence, containing all the elements of the original except those at a specified iterator, or 1540between two iterators. 1541 1542[heading Synopsis] 1543 template< 1544 typename Sequence, 1545 typename First 1546 > 1547 typename __result_of_erase__<Sequence const, First>::type erase( 1548 Sequence const& seq, First const& it1); 1549 1550 template< 1551 typename Sequence, 1552 typename First, 1553 typename Last 1554 > 1555 typename __result_of_erase__<Sequence const, First, Last>::type erase( 1556 Sequence const& seq, First const& it1, Last const& it2); 1557 1558[table Parameters 1559 [[Parameters][Requirement][Description]] 1560 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1561 [[`it1`][A model of __forward_iterator__][Iterator into `seq`]] 1562 [[`it2`][A model of __forward_iterator__][Iterator into `seq` after `it1`]] 1563] 1564 1565[heading Expression Semantics] 1566 __erase__(seq, pos); 1567 1568[*Return type]: 1569 1570* A model of __forward_sequence__. 1571* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1572 1573[*Semantics]: Returns a new sequence, containing all the elements of `seq` except the element at `pos`. 1574 1575 __erase__(seq, first, last); 1576 1577[*Return type]: 1578 1579* A model of __forward_sequence__. 1580* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1581 1582[*Semantics]: Returns a new sequence, with all the elements of `seq`, in their original order, except those 1583in the range [`first`,`last`). 1584 1585[heading Complexity] 1586Constant. Returns a view which is lazily evaluated. 1587 1588[heading Header] 1589 1590 #include <boost/fusion/algorithm/transformation/erase.hpp> 1591 #include <boost/fusion/include/erase.hpp> 1592 1593[heading Example] 1594 const __vector__<int, double, char> vec(1, 2.0, 'c'); 1595 assert(__erase__(vec, __next__(__begin__(vec))) == __make_vector__(1, 'c')); 1596 assert(__erase__(vec, __next__(__begin__(vec)), __end__(vec)) == __make_vector__(1)); 1597 1598[endsect] 1599 1600[section erase_key] 1601 1602[heading Description] 1603For an [link fusion.sequence.concepts.associative_sequence associative] __forward_sequence__ `seq`, 1604returns a [link fusion.sequence.concepts.associative_sequence associative] __forward_sequence__ containing 1605all the elements of the original except those with a given key. 1606 1607[heading Synopsis] 1608 template< 1609 typename Key, 1610 typename Sequence 1611 > 1612 typename __result_of_erase_key__<Sequence const, Key>::type erase_key(Sequence const& seq); 1613 1614[table Parameters 1615 [[Parameter][Requirement][Description]] 1616 [[`seq`][A model of __forward_sequence__ and __associative_sequence__][Operation's argument]] 1617 [[`Key`][Any type][Key to erase]] 1618] 1619 1620[heading Expression Semantics] 1621 __erase_key__<Key>(seq); 1622 1623[*Return type]: A model of __forward_sequence__ and __associative_sequence__. 1624 1625[*Semantics]: Returns a new sequence, containing all the elements of `seq`, except those with key `Key`. 1626 1627[heading Complexity] 1628Constant. Returns a view which is lazily evaluated. 1629 1630[heading Header] 1631 1632 #include <boost/fusion/algorithm/transformation/erase_key.hpp> 1633 #include <boost/fusion/include/erase_key.hpp> 1634 1635[heading Example] 1636 assert(__erase_key__<int>(__make_map__<int, long>('a', 'b')) == __make_map__<long>('b')); 1637 1638[endsect] 1639 1640[section insert] 1641 1642[heading Description] 1643Returns a new sequence with all the elements of the original, an a new element inserted the 1644position described by a given iterator. 1645 1646[heading Synopsis] 1647 template< 1648 typename Sequence, 1649 typename Pos, 1650 typename T 1651 > 1652 typename __result_of_insert__<Sequence const, Pos, T>::type insert( 1653 Sequence const& seq, Pos const& pos, T const& t); 1654 1655[table Parameters 1656 [[Parameter][Requirement][Description]] 1657 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1658 [[`pos`][A model of __forward_iterator__][The position to insert at]] 1659 [[`t`][Any type][The value to insert]] 1660] 1661 1662[heading Expression Semantics] 1663 __insert__(seq, pos, t); 1664 1665[*Return type]: 1666 1667* A model of __forward_sequence__. 1668 1669[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, and a new element with the 1670type and value of `t` inserted at iterator `pos`. 1671 1672[heading Complexity] 1673Constant. Returns a view which is lazily evaluated. 1674 1675[heading Header] 1676 1677 #include <boost/fusion/algorithm/transformation/insert.hpp> 1678 #include <boost/fusion/include/insert.hpp> 1679 1680[heading Example] 1681 const __vector__<int,int> vec(1,2); 1682 assert(__insert__(vec, __next__(__begin__(vec)), 3) == __make_vector__(1,3,2)); 1683 1684[endsect] 1685 1686[section insert_range] 1687 1688[heading Description] 1689Returns a new sequence with another sequence inserted at a specified iterator. 1690 1691[heading Synopsis] 1692 template< 1693 typename Sequence, 1694 typename Pos, 1695 typename Range 1696 > 1697 typename __result_of_insert_range__<Sequence const, Pos, Range>::type insert_range( 1698 Sequence const& seq, Pos const& pos, Range const& range); 1699 1700[table Parameters 1701 [[Parameter][Requirement][Description]] 1702 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1703 [[`pos`][A model of __forward_iterator__][The position to insert at]] 1704 [[`range`][A model of __forward_sequence__][Range to insert]] 1705] 1706 1707[heading Expression Semantics] 1708 __insert_range__(seq, pos, range); 1709 1710[*Return type]: 1711 1712* A model of __forward_sequence__. 1713* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1714 1715[*Semantics]: Returns a new sequence, containing all the elements of `seq`, and the elements of 1716`range` inserted at iterator `pos`. All elements retaining their ordering from the original sequences. 1717 1718[heading Complexity] 1719Constant. Returns a view which is lazily evaluated. 1720 1721[heading Header] 1722 1723 #include <boost/fusion/algorithm/transformation/insert_range.hpp> 1724 #include <boost/fusion/include/insert_range.hpp> 1725 1726[heading Example] 1727 const __vector__<int,int> vec(1,2); 1728 assert(__insert_range__(vec, __next__(__begin__(vec)), __make_vector__(3,4)) == __make_vector__(1,3,4,2)); 1729 1730[endsect] 1731 1732[section join] 1733 1734[heading Description] 1735Takes 2 sequences and returns a sequence containing the elements of the first followed by the elements of the second. 1736 1737[heading Synopsis] 1738 template< 1739 typename LhSequence, 1740 typename RhSequence> 1741 typename __result_of_join__<LhSequence const, RhSequence const>::type join(LhSequence const& lhs, RhSequence const& rhs); 1742 1743[table Parameters 1744 [[Parameter][Requirement][Description]] 1745 [[`lhs`][A model of __forward_sequence__][Operation's argument]] 1746 [[`rhs`][A model of __forward_sequence__][Operation's argument]] 1747] 1748 1749[heading Expression Semantics] 1750 __join__(lhs, rhs); 1751 1752[*Return type]: 1753 1754* A model of __forward_sequence__. 1755* A model of __associative_sequence__ if `lhs` and `rhs` implement the __associative_sequence__ model. 1756 1757[*Semantics]: Returns a sequence containing all the elements of `lhs` followed by all the elements of `rhs`. The order of the elements is preserved. 1758 1759[heading Complexity] 1760Constant. Returns a view which is lazily evaluated. 1761 1762[heading Header] 1763 1764 #include <boost/fusion/algorithm/transformation/join.hpp> 1765 #include <boost/fusion/include/join.hpp> 1766 1767[heading Example] 1768 __vector__<int,char> v1(1, 'a'); 1769 __vector__<int,char> v2(2, 'b'); 1770 assert(__join__(v1, v2) == __make_vector__(1,'a',2,'b')); 1771 1772[endsect] 1773 1774[section zip] 1775 1776[heading Description] 1777Zips sequences together to form a single sequence, whose members are tuples of the members of the component sequences. 1778 1779[heading Synopsis] 1780 template< 1781 typename Sequence1, 1782 typename Sequence2, 1783 ... 1784 typename SequenceN 1785 > 1786 typename __result_of_zip__<Sequence1 const, Sequence2 const, ... SequenceN const>::type 1787 zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN); 1788 1789[table Parameters 1790 [[Parameter][Requirement][Description]] 1791 [[`seq1` to `seqN`][Each sequence is a model of __forward_sequence__.][Operation's argument]] 1792] 1793 1794[heading Expression Semantics] 1795 __zip__(seq1, seq2, ... seqN); 1796 1797[*Return type]: A model of __forward_sequence__. 1798 1799[*Semantics]: Returns a sequence containing tuples of elements from sequences `seq1` to `seqN`. For example, applying zip to tuples `(1, 2, 3)` and `('a', 'b', 'c')` would return `((1, 'a'),(2, 'b'),(3, 'c'))` 1800 1801[heading Complexity] 1802Constant. Returns a view which is lazily evaluated. 1803 1804[heading Header] 1805 1806 #include <boost/fusion/algorithm/transformation/zip.hpp> 1807 #include <boost/fusion/include/zip.hpp> 1808 1809[heading Example] 1810 __vector__<int,char> v1(1, 'a'); 1811 __vector__<int,char> v2(2, 'b'); 1812 assert(__zip__(v1, v2) == __make_vector__(__make_vector__(1, 2),__make_vector__('a', 'b')); 1813 1814[endsect] 1815 1816[section pop_back] 1817 1818[heading Description] 1819Returns a new sequence, with the last element of the original removed. 1820 1821[heading Synopsis] 1822 template< 1823 typename Sequence 1824 > 1825 typename __result_of_pop_back__<Sequence const>::type pop_back(Sequence const& seq); 1826 1827[table Parameters 1828 [[Parameter][Requirement][Description]] 1829 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1830] 1831 1832[heading Expression Semantics] 1833 __pop_back__(seq); 1834 1835[*Return type]: 1836 1837* A model of __forward_sequence__. 1838* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1839 1840[*Semantics]: Returns a new sequence containing all the elements of `seq`, except the last element. The elements in the new sequence are in the same order as they were in `seq`. 1841 1842[heading Complexity] 1843Constant. Returns a view which is lazily evaluated. 1844 1845[heading Header] 1846 1847 #include <boost/fusion/algorithm/transformation/pop_back.hpp> 1848 #include <boost/fusion/include/pop_back.hpp> 1849 1850[heading Example] 1851 assert(__pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); 1852 1853[endsect] 1854 1855[section pop_front] 1856 1857[heading Description] 1858Returns a new sequence, with the first element of the original removed. 1859 1860[heading Synopsis] 1861 template< 1862 typename Sequence 1863 > 1864 typename __result_of_pop_front__<Sequence const>::type pop_front(Sequence const& seq); 1865 1866 1867[table Parameters 1868 [[Parameter][Requirement][Description]] 1869 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1870] 1871 1872[heading Expression Semantics] 1873 __pop_front__(seq); 1874 1875[*Return type]: 1876 1877* A model of __forward_sequence__. 1878* A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model. 1879 1880[*Semantics]: Returns a new sequence containing all the elements of `seq`, except the first element. The elements in the new sequence are in the same order as they were in `seq`. 1881 1882[heading Complexity] 1883Constant. Returns a view which is lazily evaluated. 1884 1885[heading Header] 1886 1887 #include <boost/fusion/algorithm/transformation/pop_front.hpp> 1888 #include <boost/fusion/include/pop_front.hpp> 1889 1890[heading Example] 1891 assert(__pop_front__(__make_vector__(1,2,3)) == __make_vector__(2,3)); 1892 1893[endsect] 1894 1895[section push_back] 1896 1897[heading Description] 1898Returns a new sequence with an element added at the end. 1899 1900[heading Synopsis] 1901 template< 1902 typename Sequence, 1903 typename T 1904 > 1905 typename __result_of_push_back__<Sequence const, T>::type push_back( 1906 Sequence const& seq, T const& t); 1907 1908[table Parameters 1909 [[Parameter][Requirement][Description]] 1910 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1911 [[`t`][Any type][The value to add to the end]] 1912] 1913 1914[heading Expression Semantics] 1915 __push_back__(seq, t); 1916 1917[*Return type]: 1918 1919* A model of __forward_sequence__. 1920 1921[*Semantics]: Returns a new sequence, containing all the elements of `seq`, and new element `t` appended to the end. The elements are in the same order as they were in `seq`. 1922 1923[heading Complexity] 1924Constant. Returns a view which is lazily evaluated. 1925 1926[heading Header] 1927 1928 #include <boost/fusion/algorithm/transformation/push_back.hpp> 1929 #include <boost/fusion/include/push_back.hpp> 1930 1931[heading Example] 1932 assert(__push_back__(__make_vector__(1,2,3),4) == __make_vector__(1,2,3,4)); 1933 1934[endsect] 1935 1936[section push_front] 1937 1938[heading Description] 1939Returns a new sequence with an element added at the beginning. 1940 1941[heading Synopsis] 1942 template< 1943 typename Sequence, 1944 typename T 1945 > 1946 typename __result_of_push_front__<Sequence const, T>::type push_front( 1947 Sequence const& seq, T const& t); 1948 1949[table Parameters 1950 [[Parameter][Requirement][Description]] 1951 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1952 [[`t`][Any type][The value to add to the beginning]] 1953] 1954 1955[heading Expression Semantics] 1956 __push_back__(seq, t); 1957 1958[*Return type]: 1959 1960* A model of __forward_sequence__. 1961 1962[*Semantics]: Returns a new sequence, containing all the elements of `seq`, and new element `t` appended to the beginning. The elements are in the same order as they were in `seq`. 1963 1964[heading Complexity] 1965Constant. Returns a view which is lazily evaluated. 1966 1967[heading Header] 1968 1969 #include <boost/fusion/algorithm/transformation/push_front.hpp> 1970 #include <boost/fusion/include/push_front.hpp> 1971 1972[heading Example] 1973 assert(__push_front__(__make_vector__(1,2,3),0) == __make_vector__(0,1,2,3)); 1974 1975[endsect] 1976 1977[section flatten] 1978 1979[heading Description] 1980Returns a new sequence without nested sequences. 1981 1982[heading Synopsis] 1983 template< 1984 typename Sequence 1985 > 1986 typename __result_of_flatten__<Sequence>::type flatten(Sequence& seq); 1987 1988 template< 1989 typename Sequence 1990 > 1991 typename __result_of_flatten__<Sequence const>::type flatten(Sequence const& seq); 1992 1993[table Parameters 1994 [[Parameter][Requirement][Description]] 1995 [[`seq`][A model of __forward_sequence__][Operation's argument]] 1996] 1997 1998[heading Expression Semantics] 1999 __flatten__(seq); 2000 2001[*Return type]: 2002 2003* A model of __forward_sequence__. 2004 2005[*Semantics]: Returns a new sequence containing all the leaf elements of `seq`. 2006 2007[heading Complexity] 2008Constant. Returns a view which is lazily evaluated. 2009 2010[heading Header] 2011 2012 #include <boost/fusion/algorithm/transformation/flatten.hpp> 2013 #include <boost/fusion/include/flatten.hpp> 2014 2015[heading Example] 2016 const __vector__<int, int, __vector__<int, int>, int> vec(1, 2, __make_vector__(3, 4), 5); 2017 assert(__flatten__(vec) == __make_vector__(1, 2, 3, 4, 5))); 2018 2019[endsect] 2020 2021[endsect] 2022 2023[section Metafunctions] 2024 2025[section filter] 2026 2027[heading Description] 2028Returns the result type of __filter__ given the sequence type and type to retain. 2029 2030[heading Synopsis] 2031 template< 2032 typename Sequence, 2033 typename T 2034 > 2035 struct filter 2036 { 2037 typedef __unspecified__ type; 2038 }; 2039 2040[table Parameter 2041 [[Parameter] [Requirement] [Description]] 2042 [[`Sequence`][A model of __forward_sequence__] [Operation's argument]] 2043 [[`T`][Any type][Type to retain]] 2044] 2045 2046[heading Expression Semantics] 2047 __result_of_filter__<Sequence, T>::type 2048 2049[*Return type]: 2050 2051* A model of __forward_sequence__. 2052* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2053 2054[*Semantics]: Returns a sequence containing the elements of `Sequence` that are of type `T`. Equivalent to `__result_of_filter_if__<Sequence, boost::is_same<mpl::_, T> >::type`. 2055 2056[heading Complexity] 2057Constant. 2058 2059[heading Header] 2060 2061 #include <boost/fusion/algorithm/transformation/filter.hpp> 2062 #include <boost/fusion/include/filter.hpp> 2063 2064[endsect] 2065 2066[section filter_if] 2067 2068[heading Description] 2069Returns the result type of __filter_if__ given the sequence and unary __mpl_lambda_expression__ predicate type. 2070 2071[heading Synopsis] 2072 template< 2073 typename Sequence, 2074 typename Pred 2075 > 2076 struct filter_if 2077 { 2078 typedef __unspecified__ type; 2079 }; 2080 2081[table Parameter 2082 [[Parameter] [Requirement] [Description]] 2083 [[`Sequence`][A model of __forward_sequence__] [Operation's argument]] 2084 [[`Pred`][A unary __mpl_lambda_expression__][Type to retain]] 2085] 2086 2087[heading Expression Semantics] 2088 __result_of_filter_if__<Sequence, Pred>::type 2089 2090[*Return type]: 2091 2092* A model of __forward_sequence__. 2093* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2094 2095[*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::true_`. 2096 2097[heading Complexity] 2098Constant. 2099 2100[heading Header] 2101 2102 #include <boost/fusion/algorithm/transformation/filter_if.hpp> 2103 #include <boost/fusion/include/filter_if.hpp> 2104 2105[endsect] 2106 2107[section transform] 2108 2109[heading Description] 2110Returns the result type of __transform__, given the types of the input sequence and unary __poly_func_obj__. 2111 2112[heading Unary version synopsis] 2113 template< 2114 typename Sequence, 2115 typename F 2116 > 2117 struct transform 2118 { 2119 typedef __unspecified__ type; 2120 }; 2121 2122[table Parameters 2123 [[Parameter][Requirement][Description]] 2124 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2125 [[`F`][A model of unary __poly_func_obj__][Transformation metafunction]] 2126] 2127 2128[heading Expression Semantics] 2129 __result_of_transform__<Sequence, F>::type 2130 2131[*Return type]: 2132 2133* A model of __forward_sequence__ 2134* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2135 2136[*Semantics]: Returns a sequence that contains the types of `__result_of__<F(E)>::type` for each element `E` within `Sequence`. 2137 2138[heading Binary version synopsis] 2139 template< 2140 typename Sequence1, 2141 typename Sequence2, 2142 typename F 2143 > 2144 struct transform 2145 { 2146 typedef __unspecified__ type; 2147 }; 2148 2149[table Parameters 2150 [[Parameter][Requirement][Description]] 2151 [[`Sequence1`][A model of __forward_sequence__][Operation's argument]] 2152 [[`Sequence2`][A model of __forward_sequence__][Operation's argument]] 2153 [[`F`][A model of binary __poly_func_obj__][Transformation metafunction]] 2154] 2155 2156[heading Expression Semantics] 2157 __result_of_transform__<Sequence1, Sequence2, F>::type 2158 2159[*Return type]: A model of __forward_sequence__. 2160 2161[*Semantics]: Returns a sequence, that contains the types of `__result_of__<F(E1, E2)>::type` for each pair of elements `E1` and `E2` within `Sequence1` and `Sequence2` respectively. 2162 2163[heading Complexity] 2164Constant. 2165 2166[heading Header] 2167 2168 #include <boost/fusion/algorithm/transformation/transform.hpp> 2169 #include <boost/fusion/include/transform.hpp> 2170 2171[endsect] 2172 2173[section replace] 2174 2175[heading Description] 2176Returns the result type of __replace__, given the types of the input sequence and element to replace. 2177 2178[heading Synopsis] 2179 template< 2180 typename Sequence, 2181 typename T 2182 > 2183 struct replace 2184 { 2185 typedef __unspecified__ type; 2186 }; 2187 2188[table Parameters 2189 [[Parameter][Requirement][Description]] 2190 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2191 [[`T`][Any type][The type of the search and replacement objects]] 2192] 2193 2194[heading Expression Semantics] 2195 __result_of_replace__<Sequence,T>::type 2196 2197[*Return type]: A model of __forward_sequence__. 2198 2199[*Semantics]: Returns the return type of __replace__. 2200 2201[heading Complexity] 2202Constant. 2203 2204[heading Header] 2205 2206 #include <boost/fusion/algorithm/transformation/replace.hpp> 2207 #include <boost/fusion/include/replace.hpp> 2208 2209[endsect] 2210 2211[section replace_if] 2212 2213[heading Description] 2214Returns the result type of __replace_if__, given the types of the sequence, unary __mpl_lambda_expression__ predicate and replacement object. 2215 2216[heading Synopsis] 2217 template< 2218 typename Sequence, 2219 typename F, 2220 typename T> 2221 struct replace_if 2222 { 2223 typedef __unspecified__ type; 2224 }; 2225 2226[table Parameters 2227 [[Parameter][Requirement][Description]] 2228 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2229 [[`F`][A model of unary __mpl_lambda_expression__][Replacement predicate]] 2230 [[`T`][Any type][The type of the replacement object]] 2231] 2232 2233[heading Expression Semantics] 2234 __result_of_replace_if__<Sequence,F,T>::type 2235 2236[*Return type]: A model of __forward_sequence__. 2237 2238[*Semantics]: Returns the return type of __replace_if__. 2239 2240[heading Complexity] 2241Constant. 2242 2243[heading Header] 2244 2245 #include <boost/fusion/algorithm/transformation/replace_if.hpp> 2246 #include <boost/fusion/include/replace_if.hpp> 2247 2248[endsect] 2249 2250[section remove] 2251 2252[heading Description] 2253Returns the result type of __remove__, given the sequence and removal types. 2254 2255[heading Synopsis] 2256 template< 2257 typename Sequence, 2258 typename T 2259 > 2260 struct remove 2261 { 2262 typedef __unspecified__ type; 2263 }; 2264 2265[table Parameters 2266 [[Parameter][Requirement][Description]] 2267 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2268 [[`T`][Any type][Remove elements of this type]] 2269] 2270 2271[heading Expression Semantics] 2272 __result_of_remove__<Sequence, T>::type 2273 2274[*Return type]: 2275 2276* A model of __forward_sequence__. 2277* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2278 2279[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_remove_if__<Sequence, boost::is_same<mpl::_, T> >::type`. 2280 2281[heading Complexity] 2282Constant. 2283 2284[heading Header] 2285 2286 #include <boost/fusion/algorithm/transformation/remove.hpp> 2287 #include <boost/fusion/include/remove.hpp> 2288 2289[endsect] 2290 2291[section remove_if] 2292 2293[heading Description] 2294Returns the result type of __remove_if__, given the input sequence and unary __mpl_lambda_expression__ predicate types. 2295 2296[heading Synopsis] 2297 template< 2298 typename Sequence, 2299 typename Pred 2300 > 2301 struct remove_if 2302 { 2303 typedef __unspecified__ type; 2304 }; 2305 2306[table Parameters 2307 [[Parameter][Requirement][Description]] 2308 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2309 [[`Pred`][A model of unary __mpl_lambda_expression__][Remove elements which evaluate to `boost::mpl::true_`]] 2310] 2311 2312[heading Expression Semantics] 2313 __result_of_remove_if__<Sequence, Pred>::type 2314 2315[*Return type]: 2316 2317* A model of __forward_sequence__. 2318* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2319 2320[*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::false_`. 2321 2322[heading Complexity] 2323Constant. 2324 2325[heading Header] 2326 2327 #include <boost/fusion/algorithm/transformation/remove_if.hpp> 2328 #include <boost/fusion/include/remove_if.hpp> 2329 2330[endsect] 2331 2332[section reverse] 2333 2334[heading Description] 2335Returns the result type of __reverse__, given the input sequence type. 2336 2337[heading Synopsis] 2338 template< 2339 typename Sequence 2340 > 2341 struct reverse 2342 { 2343 typedef __unspecified__ type; 2344 }; 2345 2346[table Parameters 2347 [[Parameter][Requirement][Description]] 2348 [[`Sequence`][A model of __bidirectional_sequence__][Operation's argument]] 2349] 2350 2351[heading Expression Semantics] 2352 __result_of_reverse__<Sequence>::type 2353 2354[*Return type]: 2355 2356* A model of __bidirectional_sequence__ if `Sequence` is a __bidirectional_sequence__ 2357else, __random_access_sequence__ if `Sequence` is a __random_access_sequence__. 2358* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2359 2360[*Semantics]: Returns a sequence with the elements in the reverse order to `Sequence`. 2361 2362[heading Complexity] 2363Constant. 2364 2365[heading Header] 2366 2367 #include <boost/fusion/algorithm/transformation/reverse.hpp> 2368 #include <boost/fusion/include/reverse.hpp> 2369 2370[endsect] 2371 2372[section clear] 2373 2374[heading Description] 2375Returns the result type of __clear__, given the input sequence type. 2376 2377[heading Synopsis] 2378 template< 2379 typename Sequence 2380 > 2381 struct clear 2382 { 2383 typedef __unspecified__ type; 2384 }; 2385 2386[table Parameters 2387 [[Parameter][Requirement][Description]] 2388 [[`Sequence`][Any type][Operation's argument]] 2389] 2390 2391[heading Expression Semantics] 2392 __result_of_clear__<Sequence>::type 2393 2394[*Return type]: A model of __forward_sequence__. 2395 2396[*Semantics]: Returns an empty sequence. 2397 2398[heading Complexity] 2399Constant. 2400 2401[heading Header] 2402 2403 #include <boost/fusion/algorithm/transformation/clear.hpp> 2404 #include <boost/fusion/include/clear.hpp> 2405 2406[endsect] 2407 2408[section erase] 2409Returns the result type of __erase__, given the input sequence and range delimiting iterator types. 2410 2411[heading Description] 2412 2413[heading Synopsis] 2414 template< 2415 typename Sequence, 2416 typename It1, 2417 typename It2 = __unspecified__> 2418 struct erase 2419 { 2420 typedef __unspecified__ type; 2421 }; 2422 2423[table Parameters 2424 [[Parameter][Requirement][Description]] 2425 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2426 [[`It1`][A model of __forward_iterator__][Operation's argument]] 2427 [[`It2`][A model of __forward_iterator__][Operation's argument]] 2428] 2429 2430[heading Expression Semantics] 2431 __result_of_erase__<Sequence, It1>::type 2432 2433[*Return type]: 2434 2435* A model of __forward_sequence__. 2436* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2437 2438[*Semantics]: Returns a new sequence with the element at `It1` removed. 2439 2440 __result_of_erase__<Sequence, It1, It2>::type 2441 2442[*Return type]: A model of __forward_sequence__. 2443 2444[*Semantics]: Returns a new sequence with the elements between `It1` and `It2` removed. 2445 2446[heading Complexity] 2447Constant. 2448 2449[heading Header] 2450 2451 #include <boost/fusion/algorithm/transformation/erase.hpp> 2452 #include <boost/fusion/include/erase.hpp> 2453 2454[endsect] 2455 2456[section erase_key] 2457 2458[heading Description] 2459Returns the result type of __erase_key__, given the sequence and key types. 2460 2461[heading Synopsis] 2462 template< 2463 typename Sequence, 2464 typename Key 2465 > 2466 struct erase_key 2467 { 2468 typedef __unspecified__ type; 2469 }; 2470 2471[table Parameters 2472 [[Parameter][Requirement][Description]] 2473 [[`Sequence`][A model of __forward_sequence__ and __associative_sequence__][Operation's argument]] 2474 [[`Key`][Any type][Key type]] 2475] 2476 2477[heading Expression Semantics] 2478 __result_of_erase_key__<Sequence, Key>::type 2479 2480[*Return type]: A model of __forward_sequence__ and __associative_sequence__. 2481 2482[*Semantics]: Returns a sequence with the elements of `Sequence`, except those with key `Key`. 2483 2484[heading Complexity] 2485Constant. 2486 2487[heading Header] 2488 2489 #include <boost/fusion/algorithm/transformation/erase_key.hpp> 2490 #include <boost/fusion/include/erase_key.hpp> 2491 2492[endsect] 2493 2494[section insert] 2495 2496[heading Description] 2497Returns the result type of __insert__, given the sequence, position iterator and insertion types. 2498 2499[heading Synopsis] 2500 template< 2501 typename Sequence, 2502 typename Position, 2503 typename T 2504 > 2505 struct insert 2506 { 2507 typedef __unspecified__ type; 2508 }; 2509 2510[table Parameters 2511 [[Parameter][Requirement][Description]] 2512 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2513 [[`Position`][A model of __forward_iterator__][Operation's argument]] 2514 [[`T`][Any type][Operation's argument]] 2515] 2516 2517[heading Expression Semantics] 2518 __result_of_insert__<Sequence, Position, T>::type 2519 2520[*Return type]: 2521 2522* A model of __forward_sequence__. 2523 2524[*Semantics]: Returns a sequence with an element of type `T` inserted at position `Position` in `Sequence`. 2525 2526[heading Complexity] 2527Constant. 2528 2529[heading Header] 2530 2531 #include <boost/fusion/algorithm/transformation/insert.hpp> 2532 #include <boost/fusion/include/insert.hpp> 2533 2534[endsect] 2535 2536[section insert_range] 2537 2538[heading Description] 2539Returns the result type of __insert_range__, given the input sequence, position iterator and insertion range types. 2540 2541[heading Synopsis] 2542 template< 2543 typename Sequence, 2544 typename Position, 2545 typename Range 2546 > 2547 struct insert_range 2548 { 2549 typedef __unspecified__ type; 2550 }; 2551 2552[table Parameters 2553 [[Parameter][Requirement][Description]] 2554 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2555 [[`Position`][A model of __forward_iterator__][Operation's argument]] 2556 [[`Range`][A model of __forward_sequence__][Operation's argument]] 2557] 2558 2559[heading Expression Semantics] 2560 __result_of_insert_range__<Sequence, Position, Range>::type 2561 2562[*Return type]: 2563 2564* A model of __forward_sequence__. 2565* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2566 2567[*Semantics]: Returns a sequence with the elements of `Range` inserted at position `Position` into `Sequence`. 2568 2569[heading Complexity] 2570Constant. 2571 2572[heading Header] 2573 2574 #include <boost/fusion/algorithm/transformation/insert_range.hpp> 2575 #include <boost/fusion/include/insert_range.hpp> 2576 2577[endsect] 2578 2579[section join] 2580 2581[heading Description] 2582Returns the result of joining 2 sequences, given the sequence types. 2583 2584[heading Synopsis] 2585 template< 2586 typename LhSequence, 2587 typename RhSequence 2588 > 2589 struct join 2590 { 2591 typedef __unspecified__ type; 2592 }; 2593 2594[heading Expression Semantics] 2595 __result_of_join__<LhSequence, RhSequence>::type 2596 2597[*Return type]: 2598 2599* A model of __forward_sequence__. 2600* A model of __associative_sequence__ if `LhSequence` and `RhSequence` implement the __associative_sequence__ model. 2601 2602[*Semantics]: Returns a sequence containing the elements of `LhSequence` followed by the elements of `RhSequence`. The order of the elements in the 2 sequences is preserved. 2603 2604[heading Complexity] 2605Constant. 2606 2607[heading Header] 2608 2609 #include <boost/fusion/algorithm/transformation/join.hpp> 2610 #include <boost/fusion/include/join.hpp> 2611 2612[endsect] 2613 2614[section zip] 2615 2616[heading Description] 2617Zips sequences together to form a single sequence, whose members are tuples of the members of the component sequences. 2618 2619[heading Synopsis] 2620 template< 2621 typename Sequence1, 2622 typename Sequence2, 2623 ... 2624 typename SequenceN 2625 > 2626 struct zip 2627 { 2628 typedef __unspecified__ type; 2629 }; 2630 2631[heading Expression Semantics] 2632 __result_of_zip__<Sequence1, Sequence2, ... SequenceN>::type 2633 2634[*Return type]: A model of the most restrictive traversal category of sequences `Sequence1` to `SequenceN`. 2635 2636[*Semantics]: Return a sequence containing tuples of elements from each sequence. For example, applying zip to tuples `(1, 2, 3)` and `('a', 'b', 'c')` would return `((1, 'a'),(2, 'b'),(3, 'c'))` 2637 2638[heading Complexity] 2639Constant. 2640 2641[heading Header] 2642 2643 #include <boost/fusion/algorithm/transformation/zip.hpp> 2644 #include <boost/fusion/include/zip.hpp> 2645 2646[endsect] 2647 2648[section pop_back] 2649 2650[heading Description] 2651Returns the result type of __pop_back__, given the input sequence type. 2652 2653[heading Synopsis] 2654 template< 2655 typename Sequence 2656 > 2657 struct pop_back 2658 { 2659 typedef __unspecified__ type; 2660 }; 2661 2662[table Parameters 2663 [[Parameter][Requirement][Description]] 2664 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2665] 2666 2667[heading Expression Semantics] 2668 __result_of_pop_back__<Sequence>::type 2669 2670[*Return type]: 2671 2672* A model of __forward_sequence__. 2673* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2674 2675[*Semantics]: Returns a sequence with all the elements of `Sequence` except the last element. 2676 2677[heading Complexity] 2678Constant. 2679 2680[heading Header] 2681 2682 #include <boost/fusion/algorithm/transformation/pop_back.hpp> 2683 #include <boost/fusion/include/pop_back.hpp> 2684 2685[endsect] 2686 2687[section pop_front] 2688 2689[heading Description] 2690Returns the result type of __pop_front__, given the input sequence type. 2691 2692[heading Synopsis] 2693 template< 2694 typename Sequence 2695 > 2696 struct pop_front 2697 { 2698 typedef __unspecified__ type; 2699 }; 2700 2701[table Parameters 2702 [[Parameter][Requirement][Description]] 2703 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2704] 2705 2706[heading Expression Semantics] 2707 __result_of_pop_front__<Sequence>::type 2708 2709[*Return type]: 2710 2711* A model of __forward_sequence__. 2712* A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. 2713 2714[*Semantics]: Returns a sequence with all the elements of `Sequence` except the first element. 2715 2716[heading Complexity] 2717Constant. 2718 2719[heading Header] 2720 2721 #include <boost/fusion/algorithm/transformation/pop_front.hpp> 2722 #include <boost/fusion/include/pop_front.hpp> 2723 2724[endsect] 2725 2726[section push_back] 2727 2728[heading Description] 2729Returns the result type of __push_back__, given the types of the input sequence and element to push. 2730 2731[heading Synopsis] 2732 template< 2733 typename Sequence, 2734 typename T 2735 > 2736 struct push_back 2737 { 2738 typedef __unspecified__ type; 2739 }; 2740 2741[table Parameters 2742 [[Parameter][Requirement][Description]] 2743 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2744 [[`T`][Any type][Operation's argument]] 2745] 2746 2747[heading Expression Semantics] 2748 __result_of_push_back__<Sequence, T>::type 2749 2750[*Return type]: 2751 2752* A model of __forward_sequence__. 2753 2754[*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the end. 2755 2756[heading Complexity] 2757Constant. 2758 2759[heading Header] 2760 2761 #include <boost/fusion/algorithm/transformation/push_back.hpp> 2762 #include <boost/fusion/include/push_back.hpp> 2763 2764[endsect] 2765 2766[section push_front] 2767 2768[heading Description] 2769Returns the result type of __push_front__, given the types of the input sequence and element to push. 2770 2771[heading Synopsis] 2772 template< 2773 typename Sequence, 2774 typename T 2775 > 2776 struct push_front 2777 { 2778 typedef __unspecified__ type; 2779 }; 2780 2781[table Parameters 2782 [[Parameter][Requirement][Description]] 2783 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2784 [[`T`][Any type][Operation's argument]] 2785] 2786 2787[heading Expression Semantics] 2788 __result_of_push_front__<Sequence, T>::type 2789 2790[*Return type]: 2791 2792* A model of __forward_sequence__. 2793 2794[*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the beginning. 2795 2796[heading Complexity] 2797Constant. 2798 2799[heading Header] 2800 2801 #include <boost/fusion/algorithm/transformation/push_front.hpp> 2802 #include <boost/fusion/include/push_front.hpp> 2803 2804[endsect] 2805 2806[section flatten] 2807 2808[heading Description] 2809Returns the result type of __flatten__, given the input sequence type. 2810 2811[heading Synopsis] 2812 template< 2813 typename Sequence 2814 > 2815 struct flatten 2816 { 2817 typedef __unspecified__ type; 2818 }; 2819 2820[table Parameters 2821 [[Parameter][Requirement][Description]] 2822 [[`Sequence`][A model of __forward_sequence__][Operation's argument]] 2823] 2824 2825[heading Expression Semantics] 2826 __result_of_flatten__<Sequence>::type 2827 2828[*Return type]: 2829 2830* A model of __forward_sequence__. 2831 2832[*Semantics]: Returns a sequence with all the leaf elements of `Sequence`. 2833 2834[heading Complexity] 2835Constant. 2836 2837[heading Header] 2838 2839 #include <boost/fusion/algorithm/transformation/flatten.hpp> 2840 #include <boost/fusion/include/flatten.hpp> 2841 2842[endsect] 2843 2844[endsect] 2845 2846[endsect] 2847 2848[endsect] 2849