algorithm.qbk 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848
  1. [/==============================================================================
  2. Copyright (C) 2001-2011 Joel de Guzman
  3. Copyright (C) 2006 Dan Marsden
  4. Copyright (C) 2010 Christopher Schmidt
  5. Use, modification and distribution is subject to the Boost Software
  6. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. ===============================================================================/]
  9. [section Algorithm]
  10. [heading Lazy Evaluation]
  11. Unlike __mpl__, Fusion algorithms are lazy[footnote Except for some
  12. special cases such as __for_each__ and __copy__ which are inherently
  13. imperative algorithms.] and non sequence-type preserving [footnote What
  14. does that mean? It means that when you operate on a sequence through a
  15. Fusion algorithm that returns a sequence, the sequence returned may not
  16. be of the same class as the original]. This is by design. Runtime
  17. efficiency is given a high priority. Like __mpl__, and unlike __stl__,
  18. fusion algorithms are mostly functional in nature such that algorithms
  19. are non mutating (no side effects). However, due to the high cost of
  20. returning full sequences such as vectors and lists, /Views/ are returned
  21. from Fusion algorithms instead. For example, the __transform__ algorithm
  22. does not actually return a transformed version of the original sequence.
  23. __transform__ returns a __transform_view__. This view holds a reference
  24. to the original sequence plus the transform function. Iteration over the
  25. __transform_view__ will apply the transform function over the sequence
  26. elements on demand. This /lazy/ evaluation scheme allows us to chain as
  27. many algorithms as we want without incurring a high runtime penalty.
  28. [heading Sequence Extension]
  29. The /lazy/ evaluation scheme where __algorithms__ return __views__ also
  30. allows operations such as __push_back__ to be totally generic. In Fusion,
  31. __push_back__ is actually a generic algorithm that works on all sequences.
  32. Given an input sequence `s` and a value `x`, Fusion's __push_back__
  33. algorithm simply returns a __joint_view__: a view that holds a reference to
  34. the original sequence `s` and the value `x`. Functions that were once
  35. sequence specific and need to be implemented N times over N different
  36. sequences are now implemented only once. That is to say that Fusion
  37. sequences are cheaply extensible.
  38. To regain the original sequence, __conversion__ functions are provided. You
  39. may use one of the __conversion__ functions to convert back to the original
  40. sequence type.
  41. [heading Header]
  42. #include <boost/fusion/algorithm.hpp>
  43. #include <boost/fusion/include/algorithm.hpp>
  44. [section Auxiliary]
  45. The auxiliary algorithms provide the utility algorithms for sequences.
  46. [heading Header]
  47. #include <boost/fusion/algorithm/auxiliary.hpp>
  48. #include <boost/fusion/include/auxiliary.hpp>
  49. [section Functions]
  50. [section copy]
  51. [heading Description]
  52. Copy a sequence `src` to a sequence `dest`.
  53. It is also used to convert sequence into other.
  54. [heading Synopsis]
  55. template <typename Seq1, typename Seq2>
  56. typename __result_of_copy__<Seq1, Seq2>::type copy(Seq1 const& src, Seq2& dest);
  57. [table Parameters
  58. [[Parameter][Requirement][Description]]
  59. [[`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]]
  60. [[`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]]
  61. ]
  62. [heading Expression Semantics]
  63. __copy__(src, dest);
  64. [*Return type]: `void`
  65. [*Semantics]: `e2 = e1` for each element `e1` in `src` and `e2` in `dest`.
  66. [heading Complexity]
  67. Linear, exactly `__result_of_size__<Sequence>::value`.
  68. [heading Header]
  69. #include <boost/fusion/algorithm/auxiliary/copy.hpp>
  70. #include <boost/fusion/include/copy.hpp>
  71. [heading Example]
  72. __vector__<int,int> vec(1,2);
  73. __list__<int,int> ls;
  74. __copy__(vec, ls);
  75. assert(ls == __make_list__(1,2));
  76. [endsect]
  77. [section move]
  78. [heading Description]
  79. move a sequence `src` to a sequence `dest`.
  80. It is also used to convert sequence into other.
  81. [heading Synopsis]
  82. template <typename Seq1, typename Seq2>
  83. typename __result_of_move__<Seq1, Seq2>::type move(Seq1&& src, Seq2& dest);
  84. [table Parameters
  85. [[Parameter][Requirement][Description]]
  86. [[`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]]
  87. [[`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]]
  88. ]
  89. [heading Expression Semantics]
  90. __move__(src, dest);
  91. [*Return type]: `void`
  92. [*Semantics]: `e2 = std::move(e1)` for each element `e1` in `src` and `e2` in `dest`.
  93. [heading Complexity]
  94. Linear, exactly `__result_of_size__<Sequence>::value`.
  95. [heading Header]
  96. #include <boost/fusion/algorithm/auxiliary/move.hpp>
  97. #include <boost/fusion/include/move.hpp>
  98. [heading Example]
  99. __vector__<int,int> vec(1,2);
  100. __list__<int,int> ls;
  101. __move__(std::move(vec), ls);
  102. assert(ls == __make_list__(1,2));
  103. [endsect]
  104. [endsect]
  105. [section Metafunctions]
  106. [section copy]
  107. [heading Description]
  108. A metafunction returning the result type of applying __copy__, which is always `void`.
  109. [heading Synopsis]
  110. template <typename Seq1, typename Seq2>
  111. struct copy
  112. {
  113. typedef void type;
  114. };
  115. [table Parameters
  116. [[Parameter] [Requirement] [Description]]
  117. [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]]
  118. [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]]
  119. ]
  120. [heading Expression Semantics]
  121. result_of::copy<Seq1, Seq2>::type
  122. [*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence.
  123. Otherwise, none.
  124. [*Semantics]: Returns the return type of __copy__ for 2 sequences of types `Seq1` and `Seq2`.
  125. [heading Complexity]
  126. Constant.
  127. [heading Header]
  128. #include <boost/fusion/algorithm/auxiliary/copy.hpp>
  129. #include <boost/fusion/include/copy.hpp>
  130. [endsect]
  131. [section move]
  132. [heading Description]
  133. A metafunction returning the result type of applying __move__, which is always `void`.
  134. [heading Synopsis]
  135. template <typename Seq1, typename Seq2>
  136. struct move
  137. {
  138. typedef void type;
  139. };
  140. [table Parameters
  141. [[Parameter] [Requirement] [Description]]
  142. [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]]
  143. [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]]
  144. ]
  145. [heading Expression Semantics]
  146. result_of::move<Seq1, Seq2>::type
  147. [*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence.
  148. Otherwise, none.
  149. [*Semantics]: Returns the return type of __move__ for 2 sequences of types `Seq1` and `Seq2`.
  150. [heading Complexity]
  151. Constant.
  152. [heading Header]
  153. #include <boost/fusion/algorithm/auxiliary/move.hpp>
  154. #include <boost/fusion/include/move.hpp>
  155. [endsect]
  156. [endsect]
  157. [endsect]
  158. [section Iteration]
  159. The iteration algorithms provide the fundamental algorithms for traversing
  160. a sequence repeatedly applying an operation to its elements.
  161. [heading Header]
  162. #include <boost/fusion/algorithm/iteration.hpp>
  163. #include <boost/fusion/include/iteration.hpp>
  164. [section Functions]
  165. [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]
  166. [heading Description]
  167. For a sequence `seq`, initial state `initial_state`, and binary function object
  168. or function pointer `f`, [^[name]] returns the result of the repeated application of
  169. binary `f` to the result of the previous `f` invocation (`inital_state` if it is
  170. the first call) and [arg_desc] of `seq`.
  171. [def name_macro [name]]
  172. [def result_of_name_macro [result_of_name]]
  173. [heading Synopsis]
  174. template<
  175. typename Sequence,
  176. typename State,
  177. typename F
  178. >
  179. typename result_of_name_macro<Sequence, State const, F>::type name_macro(
  180. Sequence& seq, State const& initial_state, F f);
  181. template<
  182. typename Sequence,
  183. typename State,
  184. typename F
  185. >
  186. typename result_of_name_macro<Sequence const, State const, F>::type name_macro(
  187. Sequence const& seq, State const& initial_state, F f);
  188. template<
  189. typename Sequence,
  190. typename State,
  191. typename F
  192. >
  193. typename result_of_name_macro<Sequence, State, F>::type name_macro(
  194. Sequence& seq, State& initial_state, F f);
  195. template<
  196. typename Sequence,
  197. typename State,
  198. typename F
  199. >
  200. typename result_of_name_macro<Sequence const, State, F>::type name_macro(
  201. Sequence const& seq, State& initial_state, F f);
  202. [def seq_concept_macro [seq_concept]]
  203. [def arg_type_id_macro [arg_type_id]]
  204. [def arg_id_macro [arg_id]]
  205. [def invoke_desc_macro [invoke_desc]]
  206. [table Parameters
  207. [[Parameter][Requirement][Description]]
  208. [[`seq`][A model of seq_concept_macro][Operation's argument]]
  209. [[`initial_state`][Any type][Initial state]]
  210. [[`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]]
  211. ]
  212. [heading Expression Semantics]
  213. name_macro(seq, initial_state, f);
  214. [*Return type]: Any type
  215. [*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].
  216. [heading Complexity]
  217. Linear, exactly `__result_of_size__<Sequence>::value` applications of `f`.
  218. [heading Header]
  219. #include <boost/fusion/algorithm/iteration/name_macro.hpp>
  220. #include <boost/fusion/include/name_macro.hpp>
  221. [def example_result_macro [example_result]]
  222. [def example_arg_transform_macro [example_arg_transform]]
  223. [heading Example]
  224. struct make_string
  225. {
  226. typedef std::string result_type;
  227. template<typename T>
  228. std::string operator()(const std::string& str, const T& t) const
  229. {
  230. return str + boost::lexical_cast<std::string>(example_arg_transform_macro);
  231. }
  232. };
  233. ...
  234. const __vector__<int,int> vec(1,2);
  235. assert(name_macro(vec,std::string(""), make_string()) == example_result_macro);
  236. ]
  237. [section fold]
  238. [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]
  239. [endsect]
  240. [section reverse_fold]
  241. [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]
  242. [endsect]
  243. [section iter_fold]
  244. [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]
  245. [endsect]
  246. [section reverse_iter_fold]
  247. [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]
  248. [endsect]
  249. [section accumulate]
  250. [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]
  251. [endsect]
  252. [section for_each]
  253. [heading Description]
  254. Applies a unary function object to each element of a sequence.
  255. [heading Synopsis]
  256. template<
  257. typename Sequence,
  258. typename F
  259. >
  260. typename __result_of_for_each__<Sequence, F>::type for_each(
  261. Sequence& seq, F f);
  262. [table Parameters
  263. [[Parameter][Requirement][Description]]
  264. [[`seq`][A model of __forward_sequence__, `f(e)` must be a valid expression for each element `e` in `seq`][Operation's argument]]
  265. [[`f`][A unary __reg_callable_obj__][Operation's argument]]
  266. ]
  267. [heading Expression Semantics]
  268. __for_each__(seq, f);
  269. [*Return type]: `void`
  270. [*Semantics]: Calls `f(e)` for each element `e` in `seq`.
  271. [heading Complexity]
  272. Linear, exactly `__result_of_size__<Sequence>::value` applications of `f`.
  273. [heading Header]
  274. #include <boost/fusion/algorithm/iteration/for_each.hpp>
  275. #include <boost/fusion/include/for_each.hpp>
  276. [heading Example]
  277. struct increment
  278. {
  279. template<typename T>
  280. void operator()(T& t) const
  281. {
  282. ++t;
  283. }
  284. };
  285. ...
  286. __vector__<int,int> vec(1,2);
  287. __for_each__(vec, increment());
  288. assert(vec == __make_vector__(2,3));
  289. [endsect]
  290. [endsect]
  291. [section Metafunctions]
  292. [template meta_fold_desc[name name_func seq_concept arg_id arg_type_id invoke_meta_desc]
  293. [heading Description]
  294. Returns the result type of [name_func].
  295. [def name_macro [name]]
  296. [heading Synopsis]
  297. template<
  298. typename Sequence,
  299. typename State,
  300. typename F>
  301. struct name_macro
  302. {
  303. typedef __unspecified__ type;
  304. };
  305. [def seq_concept_macro [seq_concept]]
  306. [def arg_type_id_macro [arg_type_id]]
  307. [def arg_id_macro [arg_id]]
  308. [def invoke_meta_desc_macro [invoke_meta_desc]]
  309. [table Parameters
  310. [[Parameter] [Requirement] [Description]]
  311. [[`Sequence`] [A model of seq_concept_macro] [The sequence to iterate]]
  312. [[`State`] [Any type] [The initial state for the first application of `F`]]
  313. [[`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]]
  314. ]
  315. [heading Expression Semantics]
  316. name_macro<Sequence, State, F>::type
  317. [*Return type]: Any type
  318. [*Semantics]: Returns the result of applying [name_func] to a sequence of type
  319. `Sequence`, with an initial state of type `State` and binary function object or
  320. function pointer of type `F`.
  321. [heading Complexity]
  322. Linear, exactly `__result_of_size__<Sequence>::value` applications of `F`.
  323. [heading Header]
  324. #include <boost/fusion/algorithm/iteration/name_macro.hpp>
  325. #include <boost/fusion/include/name_macro.hpp>
  326. ]
  327. [section fold]
  328. [meta_fold_desc fold..__fold__..__forward_sequence__..e..E..element `e` of type `E` in `seq`]
  329. [endsect]
  330. [section reverse_fold]
  331. [meta_fold_desc reverse_fold..__reverse_fold__..__bidirectional_sequence__..e..E..element `e` of type `E` in `seq`]
  332. [endsect]
  333. [section iter_fold]
  334. [meta_fold_desc iter_fold..__iter_fold__..__forward_sequence__..it..It..iterator `it` of type `It` on an element of `seq`]
  335. [endsect]
  336. [section reverse_iter_fold]
  337. [meta_fold_desc reverse_iter_fold..__reverse_iter_fold__..__bidirectional_sequence__..it..It..iterator `it` of type `It` on an element of `seq`]
  338. [endsect]
  339. [section accumulate]
  340. [meta_fold_desc accumulate..__accumulate__..__forward_sequence__..e..E..element `e` of type `E` in `seq`]
  341. [endsect]
  342. [section for_each]
  343. [heading Description]
  344. A metafunction returning the result type of applying __for_each__ to a sequence. The
  345. return type of __for_each__ is always `void`.
  346. [heading Synopsis]
  347. template<
  348. typename Sequence,
  349. typename F
  350. >
  351. struct for_each
  352. {
  353. typedef void type;
  354. };
  355. [table Parameters
  356. [[Parameter] [Requirement] [Description]]
  357. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  358. [[`F`] [Any type] [Operation's argument]]
  359. ]
  360. [heading Expression Semantics]
  361. __result_of_for_each__<Sequence, F>::type
  362. [*Return type]: `void`.
  363. [*Semantics]: Returns the return type of __for_each__ for a sequence of type `Sequence` and a unary function object `F`.
  364. The return type is always `void`.
  365. [heading Complexity]
  366. Constant.
  367. [heading Header]
  368. #include <boost/fusion/algorithm/iteration/for_each.hpp>
  369. #include <boost/fusion/include/for_each.hpp>
  370. [endsect]
  371. [endsect]
  372. [endsect]
  373. [section Query]
  374. The query algorithms provide support for searching and analyzing sequences.
  375. [heading Header]
  376. #include <boost/fusion/algorithm/query.hpp>
  377. #include <boost/fusion/include/query.hpp>
  378. [section Functions]
  379. [section any]
  380. [heading Description]
  381. For a sequence `seq` and unary function object `f`, `any` returns true if `f` returns true for at least one element of `seq`.
  382. [heading Synopsis]
  383. template<
  384. typename Sequence,
  385. typename F
  386. >
  387. typename __result_of_any__<Sequence,F>::type any(
  388. Sequence const& seq, F f);
  389. [table Parameters
  390. [[Parameter][Requirement][Description]]
  391. [[`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]]
  392. [[`f`][A unary function object][The search predicate]]
  393. ]
  394. [heading Expression semantics]
  395. __any__(seq, f);
  396. [*Return type]: `bool`
  397. [*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for some element `e` in `seq`.
  398. [heading Complexity]
  399. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  400. [heading Header]
  401. #include <boost/fusion/algorithm/query/any.hpp>
  402. #include <boost/fusion/include/any.hpp>
  403. [heading Example]
  404. struct odd
  405. {
  406. template<typename T>
  407. bool operator()(T t) const
  408. {
  409. return t % 2;
  410. }
  411. };
  412. ...
  413. assert(__any__(__make_vector__(1,2), odd()));
  414. assert(!__any__(__make_vector__(2,4), odd()));
  415. [endsect]
  416. [section all]
  417. [heading Description]
  418. For a sequence `seq` and unary function object `f`, `all` returns true if `f` returns true for every element of `seq`.
  419. [heading Synopsis]
  420. template<
  421. typename Sequence,
  422. typename F
  423. >
  424. typename __result_of_all__<Sequence,F>::type all(
  425. Sequence const& seq, F f);
  426. [table Parameters
  427. [[Parameter][Requirement][Description]]
  428. [[`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]]
  429. [[`f`][A unary function object][The search predicate]]
  430. ]
  431. [heading Expression Semantics]
  432. __all__(seq, f);
  433. [*Return type]: `bool`
  434. [*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for every element `e` in `seq`.
  435. [heading Complexity]
  436. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  437. [heading Header]
  438. #include <boost/fusion/algorithm/query/all.hpp>
  439. #include <boost/fusion/include/all.hpp>
  440. [heading Example]
  441. struct odd
  442. {
  443. template<typename T>
  444. bool operator()(T t) const
  445. {
  446. return t % 2;
  447. }
  448. };
  449. ...
  450. assert(__all__(__make_vector__(1,3), odd()));
  451. assert(!__all__(__make_vector__(1,2), odd()));
  452. [endsect]
  453. [section none]
  454. [heading Description]
  455. For a sequence `seq` and unary function object `f`, `none` returns true if `f` returns false for every element of `seq`.
  456. [heading Synopsis]
  457. template<
  458. typename Sequence,
  459. typename F
  460. >
  461. typename __result_of_none__<Sequence,F>::type none(
  462. Sequence const& seq, F f);
  463. [table Parameters
  464. [[Parameter][Requirement][Description]]
  465. [[`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]]
  466. [[`f`][A unary function object][The search predicate]]
  467. ]
  468. [heading Expression Semantics]
  469. __none__(seq, f);
  470. [*Return type]: `bool`
  471. [*Semantics]: Returns true if and only if `f(e)` evaluates to `false` for every element `e` in `seq`. Result equivalent to `!any(seq, f)`.
  472. [heading Complexity]
  473. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  474. [heading Header]
  475. #include <boost/fusion/algorithm/query/none.hpp>
  476. #include <boost/fusion/include/none.hpp>
  477. [heading Example]
  478. struct odd
  479. {
  480. template<typename T>
  481. bool operator()(T t) const
  482. {
  483. return t % 2;
  484. }
  485. };
  486. ...
  487. assert(__none__(__make_vector__(2,4), odd()));
  488. assert(!__none__(__make_vector__(1,2), odd()));
  489. [endsect]
  490. [section find]
  491. [heading Description]
  492. Finds the first element of a given type within a sequence.
  493. [heading Synopsis]
  494. template<
  495. typename T,
  496. typename Sequence
  497. >
  498. typename __result_of_find__<Sequence const, T>::type find(Sequence const& seq);
  499. template<
  500. typename T,
  501. typename Sequence
  502. >
  503. typename __result_of_find__<Sequence, T>::type find(Sequence& seq);
  504. [table Parameters
  505. [[Parameter][Requirement][Description]]
  506. [[`seq`][A model of __forward_sequence__][The sequence to search]]
  507. [[`T`][Any type][The type to search for]]
  508. ]
  509. [heading Expression Semantics]
  510. __find__<T>(seq)
  511. [*Return type]: A model of the same iterator category as the iterators of `seq`.
  512. [*Semantics]: Returns an iterator to the first element of `seq` of type `T`, or `__end__(seq)` if there is no such element.
  513. Equivalent to `__find_if__<boost::is_same<_, T> >(seq)`
  514. [heading Complexity]
  515. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  516. [heading Header]
  517. #include <boost/fusion/algorithm/query/find.hpp>
  518. #include <boost/fusion/include/find.hpp>
  519. [heading Example]
  520. const __vector__<char,int> vec('a','0');
  521. assert(*__find__<int>(vec) == '0');
  522. assert(__find__<double>(vec) == __end__(vec));
  523. [endsect]
  524. [section find_if]
  525. [heading Description]
  526. Finds the first element within a sequence with a type for which a given __mpl_lambda_expression__ evaluates to
  527. `boost::mpl::true_`.
  528. [heading Synopsis]
  529. template<
  530. typename F,
  531. typename Sequence
  532. >
  533. typename __result_of_find_if__<Sequence const, F>::type find_if(Sequence const& seq);
  534. template<
  535. typename F,
  536. typename Sequence
  537. >
  538. typename __result_of_find_if__<Sequence, F>::type find_if(Sequence& seq);
  539. [table Parameters
  540. [[Parameter][Requirement][Description]]
  541. [[`seq`][A model of __forward_sequence__][The sequence to search]]
  542. [[`F`][A unary __mpl_lambda_expression__][The search predicate]]
  543. ]
  544. [heading Expression Semantics]
  545. __find_if__<F>(seq)
  546. [*Return type]: An iterator of the same iterator category as the iterators of `seq`.
  547. [*Semantics]: Returns the first element of `seq` for which __mpl_lambda_expression__ `F` evaluates to `boost::mpl::true_`,
  548. or `__end__(seq)` if there is no such element.
  549. [heading Complexity]
  550. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  551. [heading Header]
  552. #include <boost/fusion/algorithm/query/find_if.hpp>
  553. #include <boost/fusion/include/find_if.hpp>
  554. [heading Example]
  555. const __vector__<double,int> vec(1.0,2);
  556. assert(*__find_if__<is_integral<mpl::_> >(vec) == 2);
  557. assert(__find_if__<is_class<mpl::_> >(vec) == __end__(vec));
  558. [endsect]
  559. [section count]
  560. [heading Description]
  561. Returns the number of elements of a given type within a sequence.
  562. [heading Synopsis]
  563. template<
  564. typename Sequence,
  565. typename T
  566. >
  567. typename __result_of_count__<Sequence, T>::type count(
  568. Sequence const& seq, T const& t);
  569. [table Parameters
  570. [[Parameter][Requirement][Description]]
  571. [[`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]]
  572. [[`T`][Any type][The type to count]]
  573. ]
  574. [heading Expression Semantics]
  575. __count__(seq, t);
  576. [*Return type]: `int`
  577. [*Semantics]: Returns the number of elements of type `T` and equal to `t` in `seq`.
  578. [heading Complexity]
  579. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  580. [heading Header]
  581. #include <boost/fusion/algorithm/query/count.hpp>
  582. #include <boost/fusion/include/count.hpp>
  583. [heading Example]
  584. const __vector__<double,int,int> vec(1.0,2,3);
  585. assert(__count__(vec,2) == 1);
  586. [endsect]
  587. [section count_if]
  588. [heading Description]
  589. Returns the number of elements within a sequence with a type for which a given unary function object evaluates to
  590. `true`.
  591. [heading Synopsis]
  592. template<
  593. typename Sequence,
  594. typename F
  595. >
  596. typename __result_of_count_if__<Sequence, F>::type count_if(
  597. Sequence const& seq, F f);
  598. [table Parameters
  599. [[Parameter][Requirement][Description]]
  600. [[`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]]
  601. [[`f`][A unary function object][The search predicate]]
  602. ]
  603. [heading Expression Semantics]
  604. __count_if__(seq, f)
  605. [*Return type]: `int`
  606. [*Semantics]: Returns the number of elements in `seq` where `f` evaluates to `true`.
  607. [heading Complexity]
  608. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  609. [heading Header]
  610. #include <boost/fusion/algorithm/query/count_if.hpp>
  611. #include <boost/fusion/include/count_if.hpp>
  612. [heading Example]
  613. const __vector__<int,int,int> vec(1,2,3);
  614. assert(__count_if__(vec,odd()) == 2);
  615. [endsect]
  616. [endsect]
  617. [section Metafunctions]
  618. [section any]
  619. [heading Description]
  620. A metafunction returning the result type of __any__.
  621. [heading Synopsis]
  622. template<
  623. typename Sequence,
  624. typename F
  625. >
  626. struct any
  627. {
  628. typedef bool type;
  629. };
  630. [table Parameters
  631. [[Parameter] [Requirement] [Description]]
  632. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  633. [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]
  634. ]
  635. [heading Expression Semantics]
  636. __result_of_any__<Sequence, F>::type
  637. [*Return type]: `bool`.
  638. [*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`.
  639. [heading Complexity]
  640. Constant.
  641. [heading Header]
  642. #include <boost/fusion/algorithm/query/any.hpp>
  643. #include <boost/fusion/include/any.hpp>
  644. [endsect]
  645. [section all]
  646. [heading Description]
  647. A metafunction returning the result type of __all__.
  648. [heading Synopsis]
  649. template<
  650. typename Sequence,
  651. typename F
  652. >
  653. struct all
  654. {
  655. typedef bool type;
  656. };
  657. [table Parameters
  658. [[Parameter] [Requirement] [Description]]
  659. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  660. [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]
  661. ]
  662. [heading Expression Semantics]
  663. __result_of_all__<Sequence, F>::type
  664. [*Return type]: `bool`.
  665. [*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`.
  666. [heading Complexity]
  667. Constant.
  668. [heading Header]
  669. #include <boost/fusion/algorithm/query/all.hpp>
  670. #include <boost/fusion/include/all.hpp>
  671. [endsect]
  672. [section none]
  673. [heading Description]
  674. A metafunction returning the result type of __none__.
  675. [heading Synopsis]
  676. template<
  677. typename Sequence,
  678. typename F
  679. >
  680. struct none
  681. {
  682. typedef bool type;
  683. };
  684. [table Parameters
  685. [[Parameter] [Requirement] [Description]]
  686. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  687. [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]
  688. ]
  689. [heading Expression Semantics]
  690. __result_of_none__<Sequence, F>::type
  691. [*Return type]: `bool`.
  692. [*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`.
  693. [heading Complexity]
  694. Constant.
  695. [heading Header]
  696. #include <boost/fusion/algorithm/query/none.hpp>
  697. #include <boost/fusion/include/none.hpp>
  698. [endsect]
  699. [section find]
  700. [heading Description]
  701. Returns the result type of __find__, given the sequence and search types.
  702. [heading Synopsis]
  703. template<
  704. typename Sequence,
  705. typename T
  706. >
  707. struct find
  708. {
  709. typedef __unspecified__ type;
  710. };
  711. [table Parameters
  712. [[Parameter] [Requirement] [Description]]
  713. [[`Sequence`] [Model of __forward_sequence__] [Operation's argument]]
  714. [[`T`] [Any type] [Operation's argument]]
  715. ]
  716. [heading Expression Semantics]
  717. __result_of_find__<Sequence, T>::type
  718. [*Return type]: A model of the same iterator category as the iterators of `Sequence`.
  719. [*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.
  720. [heading Complexity]
  721. Linear, at most `__result_of_size__<Sequence>::value` comparisons.
  722. [heading Header]
  723. #include <boost/fusion/algorithm/query/find.hpp>
  724. #include <boost/fusion/include/find.hpp>
  725. [endsect]
  726. [section find_if]
  727. [heading Description]
  728. Returns the result type of __find_if__ given the sequence and predicate types.
  729. [heading Synopsis]
  730. template<
  731. typename Sequence,
  732. typename Pred
  733. >
  734. struct find_if
  735. {
  736. typedef __unspecified__ type;
  737. };
  738. [table Parameters
  739. [[Parameter] [Requirement] [Description]]
  740. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  741. [[`Pred`] [A model of __mpl_lambda_expression__] [Operation's arguments]]
  742. ]
  743. [heading Expression Semantics]
  744. __result_of_find_if__<Sequence, Pred>::type
  745. [*Return type]: A model of the same iterator category as the iterators of `Sequence`.
  746. [*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.
  747. [heading Complexity]
  748. Linear. At most `__result_of_size__<Sequence>::value` comparisons.
  749. [heading Header]
  750. #include <boost/fusion/algorithm/query/find_if.hpp>
  751. #include <boost/fusion/include/find_if.hpp>
  752. [endsect]
  753. [section count]
  754. [heading Description]
  755. A metafunction that returns the result type of `count` given the sequence and search types.
  756. [heading Synopsis]
  757. template<
  758. typename Sequence,
  759. typename T
  760. >
  761. struct count
  762. {
  763. typedef int type;
  764. };
  765. [table Parameters
  766. [[Parameter] [Requirement] [heading Description]]
  767. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  768. [[`T`] [Any type] [Operation's argument]]
  769. ]
  770. [heading Expression Semantics]
  771. __result_of_count__<T>::type
  772. [*Return type]: `int`.
  773. [*Semantics]: Returns the return type of __count__. The return type is always `int`.
  774. [heading Complexity]
  775. Constant.
  776. [heading Header]
  777. #include <boost/fusion/algorithm/query/count.hpp>
  778. #include <boost/fusion/include/count.hpp>
  779. [endsect]
  780. [section count_if]
  781. [heading Description]
  782. A metafunction that returns the result type of `count_if` given the sequence and predicate types.
  783. [heading Synopsis]
  784. template<
  785. typename Sequence,
  786. typename Pred
  787. >
  788. struct count_if
  789. {
  790. typedef int type;
  791. };
  792. [table Parameters
  793. [[Parameter] [Requirement] [Description]]
  794. [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]]
  795. [[`Pred`] [A unary function object] [Operation's argument]]
  796. ]
  797. [heading Expression Semantics]
  798. __result_of_count_if__<Sequence, Pred>::type
  799. [*Return type]: `int`.
  800. [*Semantics]: Returns the return type of __count_if__. The return type is always `int`.
  801. [heading Complexity]
  802. Constant.
  803. [heading Header]
  804. #include <boost/fusion/algorithm/query/count_if.hpp>
  805. #include <boost/fusion/include/count_if.hpp>
  806. [endsect]
  807. [endsect]
  808. [endsect]
  809. [section Transformation]
  810. The 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.
  811. [note As the transformation algorithms return views onto their input arguments,
  812. it is important that the lifetime of the input arguments is greater than the
  813. period during which you wish to use the results.]
  814. [heading Header]
  815. #include <boost/fusion/algorithm/transformation.hpp>
  816. #include <boost/fusion/include/transformation.hpp>
  817. [section Functions]
  818. [section filter]
  819. [heading Description]
  820. For a given sequence, filter returns a new sequences containing only the elements of a specified type.
  821. [heading Synopsis]
  822. template<
  823. typename T,
  824. typename Sequence
  825. >
  826. typename __result_of_filter__<Sequence const, T>::type filter(Sequence const& seq);
  827. [table Parameters
  828. [[Parameter][Requirement][Description]]
  829. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  830. [[`T`][Any type][The type to retain]]
  831. ]
  832. [heading Expression Semantics]
  833. __filter__<T>(seq);
  834. [*Return type]:
  835. * A model of __forward_sequence__.
  836. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  837. [*Semantics]: Returns a sequence containing all the elements of `seq` of type `T`.
  838. Equivalent to `__filter_if__<boost::same_type<_, T> >(seq)`.
  839. [heading Complexity]
  840. Constant. Returns a view which is lazily evaluated.
  841. [heading Header]
  842. #include <boost/fusion/algorithm/transformation/filter.hpp>
  843. #include <boost/fusion/include/filter.hpp>
  844. [heading Example]
  845. const __vector__<int,int,long,long> vec(1,2,3,4);
  846. assert(__filter__<int>(vec) == __make_vector__(1,2));
  847. [endsect]
  848. [section filter_if]
  849. [heading Description]
  850. For a given sequence, __filter_if__ returns a new sequences containing
  851. only the elements with types for which a given __mpl_lambda_expression__ evaluates to `boost::mpl::true_`.
  852. [heading Synopsis]
  853. template<
  854. typename Pred,
  855. typename Sequence
  856. >
  857. typename __result_of_filter_if__<Sequence const, Pred>::type filter_if(Sequence const& seq);
  858. [table Parameters
  859. [[Parameter][Requirement][Description]]
  860. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  861. [[`Pred`][A unary __mpl_lambda_expression__][The predicate to filter by]]
  862. ]
  863. [heading Expression Semantics]
  864. __filter_if__<Pred>(seq);
  865. [*Return type]:
  866. * A model of __forward_sequence__.
  867. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  868. [*Semantics]: Returns a sequence containing all the elements of `seq` with types for which `Pred` evaluates
  869. to `boost::mpl::true_`. The order of the retained elements is the same as in the original sequence.
  870. [heading Complexity]
  871. Constant. Returns a view which is lazily evaluated.
  872. [heading Header]
  873. #include <boost/fusion/algorithm/transformation/filter_if.hpp>
  874. #include <boost/fusion/include/filter_if.hpp>
  875. [heading Example]
  876. const __vector__<int,int,double,double> vec(1,2,3.0,4.0);
  877. assert(__filter_if__<is_integral<mpl::_> >(vec) == __make_vector__(1,2));
  878. [endsect]
  879. [section transform]
  880. [heading Description]
  881. For a sequence `seq` and function object or function pointer `f`, `transform` returns a new sequence
  882. with elements created by applying `f(e)` to each element of `e` of `seq`.
  883. [heading Unary version synopsis]
  884. template<
  885. typename Sequence,
  886. typename F
  887. >
  888. typename __result_of_transform__<Sequence const, F>::type transform(
  889. Sequence const& seq, F f);
  890. [table Parameters
  891. [[Parameter][Requirement][Description]]
  892. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  893. [[`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]]
  894. ]
  895. [heading Expression Semantics]
  896. __transform__(seq, f);
  897. [*Return type]: A model of __forward_sequence__
  898. [*Semantics]: Returns a new sequence, containing the return values of `f(e)` for each element `e` within `seq`.
  899. [heading Binary version synopsis]
  900. template<
  901. typename Sequence1,
  902. typename Sequence2,
  903. typename F
  904. >
  905. typename __result_of_transform__<Sequence1 const, Sequence2 const, F>::type transform(
  906. Sequence1 const& seq1, Sequence2 const& seq2, F f);
  907. [table Parameters
  908. [[Parameter][Requirement][Description]]
  909. [[`seq1`][A model of __forward_sequence__][Operation's argument]]
  910. [[`seq2`][A model of __forward_sequence__][Operation's argument]]
  911. [[`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]]
  912. ]
  913. [*Return type]: A model of __forward_sequence__.
  914. [*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.
  915. [heading Complexity]
  916. Constant. Returns a view which is lazily evaluated.
  917. [heading Header]
  918. #include <boost/fusion/algorithm/transformation/transform.hpp>
  919. #include <boost/fusion/include/transform.hpp>
  920. [heading Example]
  921. struct triple
  922. {
  923. typedef int result_type;
  924. int operator()(int t) const
  925. {
  926. return t * 3;
  927. };
  928. };
  929. ...
  930. assert(__transform__(__make_vector__(1,2,3), triple()) == __make_vector__(3,6,9));
  931. [endsect]
  932. [section replace]
  933. [heading Description]
  934. Replaces each value within a sequence of a given type and value with a new value.
  935. [heading Synopsis]
  936. template<
  937. typename Sequence,
  938. typename T
  939. >
  940. typename __result_of_replace__<Sequence const, T>::type replace(
  941. Sequence const& seq, T const& old_value, T const& new_value);
  942. [table Parameters
  943. [[Parameter][Requirement][Description]]
  944. [[`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]]
  945. [[`old_value`][Any type][Value to replace]]
  946. [[`new_value`][Any type][Replacement value]]
  947. ]
  948. [heading Expression Semantics]
  949. __replace__(seq, old_value, new_value);
  950. [*Return type]: A model of __forward_sequence__.
  951. [*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`.
  952. [heading Complexity]
  953. Constant. Returns a view which is lazily evaluated.
  954. [heading Header]
  955. #include <boost/fusion/algorithm/transformation/replace.hpp>
  956. #include <boost/fusion/include/replace.hpp>
  957. [heading Example]
  958. assert(__replace__(__make_vector__(1,2), 2, 3) == __make_vector__(1,3));
  959. [endsect]
  960. [section replace_if]
  961. [heading Description]
  962. Replaces each element of a given sequence for which an unary function object evaluates to `true` replaced with
  963. a new value.
  964. [heading Synopsis]
  965. template<
  966. typename Sequence,
  967. typename F,
  968. typename T>
  969. typename __result_of_replace_if__<Sequence const, F, T>::type replace_if(
  970. Sequence const& seq, F f, T const& new_value);
  971. [table Parameters
  972. [[Parameter][Requirement][Description]]
  973. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  974. [[`f`][A function object for which `f(e)` is a valid expression, convertible to `bool`, for each element `e` in `seq`][Operation's argument]]
  975. [[`new_value`][Any type][Replacement value]]
  976. ]
  977. [heading Expression Semantics]
  978. __replace_if__(seq, f, new_value);
  979. [*Return type]: A model of __forward_sequence__.
  980. [*Semantics]: Returns a new sequence with all the elements of `seq`,
  981. with `new_value` assigned to each element for which `f` evaluates to `true`.
  982. [heading Complexity]
  983. Constant. Returns a view which is lazily evaluated.
  984. [heading Header]
  985. #include <boost/fusion/algorithm/transformation/replace_if.hpp>
  986. #include <boost/fusion/include/replace_if.hpp>
  987. [heading Example]
  988. struct odd
  989. {
  990. template<typename T>
  991. bool operator()(T t) const
  992. {
  993. return t % 2;
  994. }
  995. };
  996. ...
  997. assert(__replace_if__(__make_vector__(1,2), odd(), 3) == __make_vector__(3,2));
  998. [endsect]
  999. [section remove]
  1000. [heading Description]
  1001. Returns a new sequence, with all the elements of the original sequence, except those of a given type.
  1002. [heading Synopsis]
  1003. template<
  1004. typename T,
  1005. typename Sequence
  1006. >
  1007. typename __result_of_remove__<Sequence const, T>::type remove(Sequence const& seq);
  1008. [table Parameters
  1009. [[Parameter][Requirement][Description]]
  1010. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1011. [[`T`][Any type][Type to remove]]
  1012. ]
  1013. [heading Expression Semantics]
  1014. __remove__<T>(seq);
  1015. [*Return type]:
  1016. * A model of __forward_sequence__.
  1017. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1018. [*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except
  1019. those of type `T`. Equivalent to `__remove_if__<boost::is_same<_,T> >(seq)`.
  1020. [heading Complexity]
  1021. Constant. Returns a view which is lazily evaluated.
  1022. [heading Header]
  1023. #include <boost/fusion/algorithm/transformation/remove.hpp>
  1024. #include <boost/fusion/include/remove.hpp>
  1025. [heading Example]
  1026. const __vector__<int,double> vec(1,2.0);
  1027. assert(__remove__<double>(vec) == __make_vector__(1));
  1028. [endsect]
  1029. [section remove_if]
  1030. [heading Description]
  1031. Returns a new sequence, containing all the elements of the original except those where a given unary
  1032. function object evaluates to `true`.
  1033. [heading Synopsis]
  1034. template<
  1035. typename Pred,
  1036. typename Sequence
  1037. >
  1038. typename __result_of_remove_if__<Sequence const, Pred>::type remove_if(Sequence const& seq);
  1039. [table Parameters
  1040. [[Parameter][Requirement][Description]]
  1041. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1042. [[`Pred`][A model of unary __mpl_lambda_expression__][Removal predicate]]
  1043. ]
  1044. [heading Expression Semantics]
  1045. __remove_if__<Pred>(seq);
  1046. [*Return type]:
  1047. * A model of __forward_sequence__.
  1048. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1049. [*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except
  1050. those elements with types for which `Pred` evaluates to `boost::mpl::true_`.
  1051. Equivalent to `__filter__<boost::mpl::not_<Pred> >(seq)`.
  1052. [heading Complexity]
  1053. Constant. Returns a view which is lazily evaluated.
  1054. [heading Header]
  1055. #include <boost/fusion/algorithm/transformation/remove_if.hpp>
  1056. #include <boost/fusion/include/remove_if.hpp>
  1057. [heading Example]
  1058. const __vector__<int,double> vec(1,2.0);
  1059. assert(__remove_if__<is_floating_point<mpl::_> >(vec) == __make_vector__(1));
  1060. [endsect]
  1061. [section reverse]
  1062. [heading Description]
  1063. Returns a new sequence with the elements of the original in reverse order.
  1064. [heading Synopsis]
  1065. template<
  1066. typename Sequence
  1067. >
  1068. typename __result_of_reverse__<Sequence const>::type reverse(Sequence const& seq);
  1069. [table Parameters
  1070. [[Parameter][Requirement][Description]]
  1071. [[`seq`][A model of __bidirectional_sequence__][Operation's argument]]
  1072. ]
  1073. [heading Expression Semantics]
  1074. __reverse__(seq);
  1075. [*Return type]:
  1076. * A model of __bidirectional_sequence__ if `seq` is a __bidirectional_sequence__
  1077. else, __random_access_sequence__ if `seq` is a __random_access_sequence__.
  1078. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1079. [*Semantics]: Returns a new sequence containing all the elements of `seq` in reverse order.
  1080. [heading Complexity]
  1081. Constant. Returns a view which is lazily evaluated.
  1082. [heading Header]
  1083. #include <boost/fusion/algorithm/transformation/reverse.hpp>
  1084. #include <boost/fusion/include/reverse.hpp>
  1085. [heading Example]
  1086. assert(__reverse__(__make_vector__(1,2,3)) == __make_vector__(3,2,1));
  1087. [endsect]
  1088. [section clear]
  1089. [heading Description]
  1090. __clear__ returns an empty sequence.
  1091. [heading Synopsis]
  1092. template<
  1093. typename Sequence
  1094. >
  1095. typename __result_of_clear__<Sequence const>::type clear(Sequence const& seq);
  1096. [table Parameters
  1097. [[Parameter][Requirement][Description]]
  1098. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1099. ]
  1100. [heading Expression Semantics]
  1101. __clear__(seq);
  1102. [*Return type]: A model of __forward_sequence__.
  1103. [*Expression Semantics]: Returns a sequence with no elements.
  1104. [heading Complexity]
  1105. Constant.
  1106. [heading Header]
  1107. #include <boost/fusion/algorithm/transformation/clear.hpp>
  1108. #include <boost/fusion/include/clear.hpp>
  1109. [heading Example]
  1110. assert(__clear__(__make_vector__(1,2,3)) == __make_vector__());
  1111. [endsect]
  1112. [section erase]
  1113. [heading Description]
  1114. Returns a new sequence, containing all the elements of the original except those at a specified iterator, or
  1115. between two iterators.
  1116. [heading Synopsis]
  1117. template<
  1118. typename Sequence,
  1119. typename First
  1120. >
  1121. typename __result_of_erase__<Sequence const, First>::type erase(
  1122. Sequence const& seq, First const& it1);
  1123. template<
  1124. typename Sequence,
  1125. typename First,
  1126. typename Last
  1127. >
  1128. typename __result_of_erase__<Sequence const, First, Last>::type erase(
  1129. Sequence const& seq, First const& it1, Last const& it2);
  1130. [table Parameters
  1131. [[Parameters][Requirement][Description]]
  1132. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1133. [[`it1`][A model of __forward_iterator__][Iterator into `seq`]]
  1134. [[`it2`][A model of __forward_iterator__][Iterator into `seq` after `it1`]]
  1135. ]
  1136. [heading Expression Semantics]
  1137. __erase__(seq, pos);
  1138. [*Return type]:
  1139. * A model of __forward_sequence__.
  1140. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1141. [*Semantics]: Returns a new sequence, containing all the elements of `seq` except the element at `pos`.
  1142. __erase__(seq, first, last);
  1143. [*Return type]:
  1144. * A model of __forward_sequence__.
  1145. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1146. [*Semantics]: Returns a new sequence, with all the elements of `seq`, in their original order, except those
  1147. in the range [`first`,`last`).
  1148. [heading Complexity]
  1149. Constant. Returns a view which is lazily evaluated.
  1150. [heading Header]
  1151. #include <boost/fusion/algorithm/transformation/erase.hpp>
  1152. #include <boost/fusion/include/erase.hpp>
  1153. [heading Example]
  1154. const __vector__<int, double, char> vec(1, 2.0, 'c');
  1155. assert(__erase__(vec, __next__(__begin__(vec))) == __make_vector__(1, 'c'));
  1156. assert(__erase__(vec, __next__(__begin__(vec)), __end__(vec)) == __make_vector__(1));
  1157. [endsect]
  1158. [section erase_key]
  1159. [heading Description]
  1160. For an [link fusion.sequence.concepts.associative_sequence associative] __forward_sequence__ `seq`,
  1161. returns a [link fusion.sequence.concepts.associative_sequence associative] __forward_sequence__ containing
  1162. all the elements of the original except those with a given key.
  1163. [heading Synopsis]
  1164. template<
  1165. typename Key,
  1166. typename Sequence
  1167. >
  1168. typename __result_of_erase_key__<Sequence const, Key>::type erase_key(Sequence const& seq);
  1169. [table Parameters
  1170. [[Parameter][Requirement][Description]]
  1171. [[`seq`][A model of __forward_sequence__ and __associative_sequence__][Operation's argument]]
  1172. [[`Key`][Any type][Key to erase]]
  1173. ]
  1174. [heading Expression Semantics]
  1175. __erase_key__<Key>(seq);
  1176. [*Return type]: A model of __forward_sequence__ and __associative_sequence__.
  1177. [*Semantics]: Returns a new sequence, containing all the elements of `seq`, except those with key `Key`.
  1178. [heading Complexity]
  1179. Constant. Returns a view which is lazily evaluated.
  1180. [heading Header]
  1181. #include <boost/fusion/algorithm/transformation/erase_key.hpp>
  1182. #include <boost/fusion/include/erase_key.hpp>
  1183. [heading Example]
  1184. assert(__erase_key__<int>(__make_map__<int, long>('a', 'b')) == __make_map__<long>('b'));
  1185. [endsect]
  1186. [section insert]
  1187. [heading Description]
  1188. Returns a new sequence with all the elements of the original, an a new element inserted the
  1189. position described by a given iterator.
  1190. [heading Synopsis]
  1191. template<
  1192. typename Sequence,
  1193. typename Pos,
  1194. typename T
  1195. >
  1196. typename __result_of_insert__<Sequence const, Pos, T>::type insert(
  1197. Sequence const& seq, Pos const& pos, T const& t);
  1198. [table Parameters
  1199. [[Parameter][Requirement][Description]]
  1200. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1201. [[`pos`][A model of __forward_iterator__][The position to insert at]]
  1202. [[`t`][Any type][The value to insert]]
  1203. ]
  1204. [heading Expression Semantics]
  1205. __insert__(seq, pos, t);
  1206. [*Return type]:
  1207. * A model of __forward_sequence__.
  1208. [*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, and a new element with the
  1209. type and value of `t` inserted at iterator `pos`.
  1210. [heading Complexity]
  1211. Constant. Returns a view which is lazily evaluated.
  1212. [heading Header]
  1213. #include <boost/fusion/algorithm/transformation/insert.hpp>
  1214. #include <boost/fusion/include/insert.hpp>
  1215. [heading Example]
  1216. const __vector__<int,int> vec(1,2);
  1217. assert(__insert__(vec, __next__(__begin__(vec)), 3) == __make_vector__(1,3,2));
  1218. [endsect]
  1219. [section insert_range]
  1220. [heading Description]
  1221. Returns a new sequence with another sequence inserted at a specified iterator.
  1222. [heading Synopsis]
  1223. template<
  1224. typename Sequence,
  1225. typename Pos,
  1226. typename Range
  1227. >
  1228. typename __result_of_insert_range__<Sequence const, Pos, Range>::type insert_range(
  1229. Sequence const& seq, Pos const& pos, Range const& range);
  1230. [table Parameters
  1231. [[Parameter][Requirement][Description]]
  1232. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1233. [[`pos`][A model of __forward_iterator__][The position to insert at]]
  1234. [[`range`][A model of __forward_sequence__][Range to insert]]
  1235. ]
  1236. [heading Expression Semantics]
  1237. __insert_range__(seq, pos, range);
  1238. [*Return type]:
  1239. * A model of __forward_sequence__.
  1240. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1241. [*Semantics]: Returns a new sequence, containing all the elements of `seq`, and the elements of
  1242. `range` inserted at iterator `pos`. All elements retaining their ordering from the original sequences.
  1243. [heading Complexity]
  1244. Constant. Returns a view which is lazily evaluated.
  1245. [heading Header]
  1246. #include <boost/fusion/algorithm/transformation/insert_range.hpp>
  1247. #include <boost/fusion/include/insert_range.hpp>
  1248. [heading Example]
  1249. const __vector__<int,int> vec(1,2);
  1250. assert(__insert_range__(vec, __next__(__begin__(vec)), __make_vector__(3,4)) == __make_vector__(1,3,4,2));
  1251. [endsect]
  1252. [section join]
  1253. [heading Description]
  1254. Takes 2 sequences and returns a sequence containing the elements of the first followed by the elements of the second.
  1255. [heading Synopsis]
  1256. template<
  1257. typename LhSequence,
  1258. typename RhSequence>
  1259. typename __result_of_join__<LhSequence const, RhSequence const>::type join(LhSequence const& lhs, RhSequence const& rhs);
  1260. [table Parameters
  1261. [[Parameter][Requirement][Description]]
  1262. [[`lhs`][A model of __forward_sequence__][Operation's argument]]
  1263. [[`rhs`][A model of __forward_sequence__][Operation's argument]]
  1264. ]
  1265. [heading Expression Semantics]
  1266. __join__(lhs, rhs);
  1267. [*Return type]:
  1268. * A model of __forward_sequence__.
  1269. * A model of __associative_sequence__ if `lhs` and `rhs` implement the __associative_sequence__ model.
  1270. [*Semantics]: Returns a sequence containing all the elements of `lhs` followed by all the elements of `rhs`. The order of the elements is preserved.
  1271. [heading Complexity]
  1272. Constant. Returns a view which is lazily evaluated.
  1273. [heading Header]
  1274. #include <boost/fusion/algorithm/transformation/join.hpp>
  1275. #include <boost/fusion/include/join.hpp>
  1276. [heading Example]
  1277. __vector__<int,char> v1(1, 'a');
  1278. __vector__<int,char> v2(2, 'b');
  1279. assert(__join__(v1, v2) == __make_vector__(1,'a',2,'b'));
  1280. [endsect]
  1281. [section zip]
  1282. [heading Description]
  1283. Zips sequences together to form a single sequence, whose members are tuples of the members of the component sequences.
  1284. [heading Synopsis]
  1285. template<
  1286. typename Sequence1,
  1287. typename Sequence2,
  1288. ...
  1289. typename SequenceN
  1290. >
  1291. typename __result_of_zip__<Sequence1 const, Sequence2 const, ... SequenceN const>::type
  1292. zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN);
  1293. [table Parameters
  1294. [[Parameter][Requirement][Description]]
  1295. [[`seq1` to `seqN`][Each sequence is a model of __forward_sequence__.][Operation's argument]]
  1296. ]
  1297. [heading Expression Semantics]
  1298. __zip__(seq1, seq2, ... seqN);
  1299. [*Return type]: A model of __forward_sequence__.
  1300. [*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'))`
  1301. [heading Complexity]
  1302. Constant. Returns a view which is lazily evaluated.
  1303. [heading Header]
  1304. #include <boost/fusion/algorithm/transformation/zip.hpp>
  1305. #include <boost/fusion/include/zip.hpp>
  1306. [heading Example]
  1307. __vector__<int,char> v1(1, 'a');
  1308. __vector__<int,char> v2(2, 'b');
  1309. assert(__zip__(v1, v2) == __make_vector__(__make_vector__(1, 2),__make_vector__('a', 'b'));
  1310. [endsect]
  1311. [section pop_back]
  1312. [heading Description]
  1313. Returns a new sequence, with the last element of the original removed.
  1314. [heading Synopsis]
  1315. template<
  1316. typename Sequence
  1317. >
  1318. typename __result_of_pop_back__<Sequence const>::type pop_back(Sequence const& seq);
  1319. [table Parameters
  1320. [[Parameter][Requirement][Description]]
  1321. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1322. ]
  1323. [heading Expression Semantics]
  1324. __pop_back__(seq);
  1325. [*Return type]:
  1326. * A model of __forward_sequence__.
  1327. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1328. [*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`.
  1329. [heading Complexity]
  1330. Constant. Returns a view which is lazily evaluated.
  1331. [heading Header]
  1332. #include <boost/fusion/algorithm/transformation/pop_back.hpp>
  1333. #include <boost/fusion/include/pop_back.hpp>
  1334. [heading Example]
  1335. assert(__pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2));
  1336. [endsect]
  1337. [section pop_front]
  1338. [heading Description]
  1339. Returns a new sequence, with the first element of the original removed.
  1340. [heading Synopsis]
  1341. template<
  1342. typename Sequence
  1343. >
  1344. typename __result_of_pop_front__<Sequence const>::type pop_front(Sequence const& seq);
  1345. [table Parameters
  1346. [[Parameter][Requirement][Description]]
  1347. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1348. ]
  1349. [heading Expression Semantics]
  1350. __pop_front__(seq);
  1351. [*Return type]:
  1352. * A model of __forward_sequence__.
  1353. * A model of __associative_sequence__ if `seq` implements the __associative_sequence__ model.
  1354. [*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`.
  1355. [heading Complexity]
  1356. Constant. Returns a view which is lazily evaluated.
  1357. [heading Header]
  1358. #include <boost/fusion/algorithm/transformation/pop_front.hpp>
  1359. #include <boost/fusion/include/pop_front.hpp>
  1360. [heading Example]
  1361. assert(__pop_front__(__make_vector__(1,2,3)) == __make_vector__(2,3));
  1362. [endsect]
  1363. [section push_back]
  1364. [heading Description]
  1365. Returns a new sequence with an element added at the end.
  1366. [heading Synopsis]
  1367. template<
  1368. typename Sequence,
  1369. typename T
  1370. >
  1371. typename __result_of_push_back__<Sequence const, T>::type push_back(
  1372. Sequence const& seq, T const& t);
  1373. [table Parameters
  1374. [[Parameter][Requirement][Description]]
  1375. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1376. [[`t`][Any type][The value to add to the end]]
  1377. ]
  1378. [heading Expression Semantics]
  1379. __push_back__(seq, t);
  1380. [*Return type]:
  1381. * A model of __forward_sequence__.
  1382. [*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`.
  1383. [heading Complexity]
  1384. Constant. Returns a view which is lazily evaluated.
  1385. [heading Header]
  1386. #include <boost/fusion/algorithm/transformation/push_back.hpp>
  1387. #include <boost/fusion/include/push_back.hpp>
  1388. [heading Example]
  1389. assert(__push_back__(__make_vector__(1,2,3),4) == __make_vector__(1,2,3,4));
  1390. [endsect]
  1391. [section push_front]
  1392. [heading Description]
  1393. Returns a new sequence with an element added at the beginning.
  1394. [heading Synopsis]
  1395. template<
  1396. typename Sequence,
  1397. typename T
  1398. >
  1399. typename __result_of_push_front__<Sequence const, T>::type push_front(
  1400. Sequence const& seq, T const& t);
  1401. [table Parameters
  1402. [[Parameter][Requirement][Description]]
  1403. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1404. [[`t`][Any type][The value to add to the beginning]]
  1405. ]
  1406. [heading Expression Semantics]
  1407. __push_back__(seq, t);
  1408. [*Return type]:
  1409. * A model of __forward_sequence__.
  1410. [*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`.
  1411. [heading Complexity]
  1412. Constant. Returns a view which is lazily evaluated.
  1413. [heading Header]
  1414. #include <boost/fusion/algorithm/transformation/push_front.hpp>
  1415. #include <boost/fusion/include/push_front.hpp>
  1416. [heading Example]
  1417. assert(__push_front__(__make_vector__(1,2,3),0) == __make_vector__(0,1,2,3));
  1418. [endsect]
  1419. [section flatten]
  1420. [heading Description]
  1421. Returns a new sequence without nested sequences.
  1422. [heading Synopsis]
  1423. template<
  1424. typename Sequence
  1425. >
  1426. typename __result_of_flatten__<Sequence>::type flatten(Sequence& seq);
  1427. template<
  1428. typename Sequence
  1429. >
  1430. typename __result_of_flatten__<Sequence const>::type flatten(Sequence const& seq);
  1431. [table Parameters
  1432. [[Parameter][Requirement][Description]]
  1433. [[`seq`][A model of __forward_sequence__][Operation's argument]]
  1434. ]
  1435. [heading Expression Semantics]
  1436. __flatten__(seq);
  1437. [*Return type]:
  1438. * A model of __forward_sequence__.
  1439. [*Semantics]: Returns a new sequence containing all the leaf elements of `seq`.
  1440. [heading Complexity]
  1441. Constant. Returns a view which is lazily evaluated.
  1442. [heading Header]
  1443. #include <boost/fusion/algorithm/transformation/flatten.hpp>
  1444. #include <boost/fusion/include/flatten.hpp>
  1445. [heading Example]
  1446. const __vector__<int, int, __vector__<int, int>, int> vec(1, 2, __make_vector__(3, 4), 5);
  1447. assert(__flatten__(vec) == __make_vector__(1, 2, 3, 4, 5)));
  1448. [endsect]
  1449. [endsect]
  1450. [section Metafunctions]
  1451. [section filter]
  1452. [heading Description]
  1453. Returns the result type of __filter__ given the sequence type and type to retain.
  1454. [heading Synopsis]
  1455. template<
  1456. typename Sequence,
  1457. typename T
  1458. >
  1459. struct filter
  1460. {
  1461. typedef __unspecified__ type;
  1462. };
  1463. [table Parameter
  1464. [[Parameter] [Requirement] [Description]]
  1465. [[`Sequence`][A model of __forward_sequence__] [Operation's argument]]
  1466. [[`T`][Any type][Type to retain]]
  1467. ]
  1468. [heading Expression Semantics]
  1469. __result_of_filter__<Sequence, T>::type
  1470. [*Return type]:
  1471. * A model of __forward_sequence__.
  1472. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1473. [*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`.
  1474. [heading Complexity]
  1475. Constant.
  1476. [heading Header]
  1477. #include <boost/fusion/algorithm/transformation/filter.hpp>
  1478. #include <boost/fusion/include/filter.hpp>
  1479. [endsect]
  1480. [section filter_if]
  1481. [heading Description]
  1482. Returns the result type of __filter_if__ given the sequence and unary __mpl_lambda_expression__ predicate type.
  1483. [heading Synopsis]
  1484. template<
  1485. typename Sequence,
  1486. typename Pred
  1487. >
  1488. struct filter_if
  1489. {
  1490. typedef __unspecified__ type;
  1491. };
  1492. [table Parameter
  1493. [[Parameter] [Requirement] [Description]]
  1494. [[`Sequence`][A model of __forward_sequence__] [Operation's argument]]
  1495. [[`Pred`][A unary __mpl_lambda_expression__][Type to retain]]
  1496. ]
  1497. [heading Expression Semantics]
  1498. __result_of_filter_if__<Sequence, Pred>::type
  1499. [*Return type]:
  1500. * A model of __forward_sequence__.
  1501. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1502. [*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::true_`.
  1503. [heading Complexity]
  1504. Constant.
  1505. [heading Header]
  1506. #include <boost/fusion/algorithm/transformation/filter_if.hpp>
  1507. #include <boost/fusion/include/filter_if.hpp>
  1508. [endsect]
  1509. [section transform]
  1510. [heading Description]
  1511. Returns the result type of __transform__, given the types of the input sequence and unary __poly_func_obj__.
  1512. [heading Unary version synopsis]
  1513. template<
  1514. typename Sequence,
  1515. typename F
  1516. >
  1517. struct transform
  1518. {
  1519. typedef __unspecified__ type;
  1520. };
  1521. [table Parameters
  1522. [[Parameter][Requirement][Description]]
  1523. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1524. [[`F`][A model of unary __poly_func_obj__][Transformation metafunction]]
  1525. ]
  1526. [heading Expression Semantics]
  1527. __result_of_transform__<Sequence, F>::type
  1528. [*Return type]:
  1529. * A model of __forward_sequence__
  1530. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1531. [*Semantics]: Returns a sequence that contains the types of `__result_of__<F(E)>::type` for each element `E` within `Sequence`.
  1532. [heading Binary version synopsis]
  1533. template<
  1534. typename Sequence1,
  1535. typename Sequence2,
  1536. typename F
  1537. >
  1538. struct transform
  1539. {
  1540. typedef __unspecified__ type;
  1541. };
  1542. [table Parameters
  1543. [[Parameter][Requirement][Description]]
  1544. [[`Sequence1`][A model of __forward_sequence__][Operation's argument]]
  1545. [[`Sequence2`][A model of __forward_sequence__][Operation's argument]]
  1546. [[`F`][A model of binary __poly_func_obj__][Transformation metafunction]]
  1547. ]
  1548. [heading Expression Semantics]
  1549. __result_of_transform__<Sequence1, Sequence2, F>::type
  1550. [*Return type]: A model of __forward_sequence__.
  1551. [*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.
  1552. [heading Complexity]
  1553. Constant.
  1554. [heading Header]
  1555. #include <boost/fusion/algorithm/transformation/transform.hpp>
  1556. #include <boost/fusion/include/transform.hpp>
  1557. [endsect]
  1558. [section replace]
  1559. [heading Description]
  1560. Returns the result type of __replace__, given the types of the input sequence and element to replace.
  1561. [heading Synopsis]
  1562. template<
  1563. typename Sequence,
  1564. typename T
  1565. >
  1566. struct replace
  1567. {
  1568. typedef __unspecified__ type;
  1569. };
  1570. [table Parameters
  1571. [[Parameter][Requirement][Description]]
  1572. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1573. [[`T`][Any type][The type of the search and replacement objects]]
  1574. ]
  1575. [heading Expression Semantics]
  1576. __result_of_replace__<Sequence,T>::type
  1577. [*Return type]: A model of __forward_sequence__.
  1578. [*Semantics]: Returns the return type of __replace__.
  1579. [heading Complexity]
  1580. Constant.
  1581. [heading Header]
  1582. #include <boost/fusion/algorithm/transformation/replace.hpp>
  1583. #include <boost/fusion/include/replace.hpp>
  1584. [endsect]
  1585. [section replace_if]
  1586. [heading Description]
  1587. Returns the result type of __replace_if__, given the types of the sequence, unary __mpl_lambda_expression__ predicate and replacement object.
  1588. [heading Synopsis]
  1589. template<
  1590. typename Sequence,
  1591. typename F,
  1592. typename T>
  1593. struct replace_if
  1594. {
  1595. typedef __unspecified__ type;
  1596. };
  1597. [table Parameters
  1598. [[Parameter][Requirement][Description]]
  1599. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1600. [[`F`][A model of unary __mpl_lambda_expression__][Replacement predicate]]
  1601. [[`T`][Any type][The type of the replacement object]]
  1602. ]
  1603. [heading Expression Semantics]
  1604. __result_of_replace_if__<Sequence,F,T>::type
  1605. [*Return type]: A model of __forward_sequence__.
  1606. [*Semantics]: Returns the return type of __replace_if__.
  1607. [heading Complexity]
  1608. Constant.
  1609. [heading Header]
  1610. #include <boost/fusion/algorithm/transformation/replace_if.hpp>
  1611. #include <boost/fusion/include/replace_if.hpp>
  1612. [endsect]
  1613. [section remove]
  1614. [heading Description]
  1615. Returns the result type of __remove__, given the sequence and removal types.
  1616. [heading Synopsis]
  1617. template<
  1618. typename Sequence,
  1619. typename T
  1620. >
  1621. struct remove
  1622. {
  1623. typedef __unspecified__ type;
  1624. };
  1625. [table Parameters
  1626. [[Parameter][Requirement][Description]]
  1627. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1628. [[`T`][Any type][Remove elements of this type]]
  1629. ]
  1630. [heading Expression Semantics]
  1631. __result_of_remove__<Sequence, T>::type
  1632. [*Return type]:
  1633. * A model of __forward_sequence__.
  1634. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1635. [*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`.
  1636. [heading Complexity]
  1637. Constant.
  1638. [heading Header]
  1639. #include <boost/fusion/algorithm/transformation/remove.hpp>
  1640. #include <boost/fusion/include/remove.hpp>
  1641. [endsect]
  1642. [section remove_if]
  1643. [heading Description]
  1644. Returns the result type of __remove_if__, given the input sequence and unary __mpl_lambda_expression__ predicate types.
  1645. [heading Synopsis]
  1646. template<
  1647. typename Sequence,
  1648. typename Pred
  1649. >
  1650. struct remove_if
  1651. {
  1652. typedef __unspecified__ type;
  1653. };
  1654. [table Parameters
  1655. [[Parameter][Requirement][Description]]
  1656. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1657. [[`Pred`][A model of unary __mpl_lambda_expression__][Remove elements which evaluate to `boost::mpl::true_`]]
  1658. ]
  1659. [heading Expression Semantics]
  1660. __result_of_remove_if__<Sequence, Pred>::type
  1661. [*Return type]:
  1662. * A model of __forward_sequence__.
  1663. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1664. [*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::false_`.
  1665. [heading Complexity]
  1666. Constant.
  1667. [heading Header]
  1668. #include <boost/fusion/algorithm/transformation/remove_if.hpp>
  1669. #include <boost/fusion/include/remove_if.hpp>
  1670. [endsect]
  1671. [section reverse]
  1672. [heading Description]
  1673. Returns the result type of __reverse__, given the input sequence type.
  1674. [heading Synopsis]
  1675. template<
  1676. typename Sequence
  1677. >
  1678. struct reverse
  1679. {
  1680. typedef __unspecified__ type;
  1681. };
  1682. [table Parameters
  1683. [[Parameter][Requirement][Description]]
  1684. [[`Sequence`][A model of __bidirectional_sequence__][Operation's argument]]
  1685. ]
  1686. [heading Expression Semantics]
  1687. __result_of_reverse__<Sequence>::type
  1688. [*Return type]:
  1689. * A model of __bidirectional_sequence__ if `Sequence` is a __bidirectional_sequence__
  1690. else, __random_access_sequence__ if `Sequence` is a __random_access_sequence__.
  1691. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1692. [*Semantics]: Returns a sequence with the elements in the reverse order to `Sequence`.
  1693. [heading Complexity]
  1694. Constant.
  1695. [heading Header]
  1696. #include <boost/fusion/algorithm/transformation/reverse.hpp>
  1697. #include <boost/fusion/include/reverse.hpp>
  1698. [endsect]
  1699. [section clear]
  1700. [heading Description]
  1701. Returns the result type of __clear__, given the input sequence type.
  1702. [heading Synopsis]
  1703. template<
  1704. typename Sequence
  1705. >
  1706. struct clear
  1707. {
  1708. typedef __unspecified__ type;
  1709. };
  1710. [table Parameters
  1711. [[Parameter][Requirement][Description]]
  1712. [[`Sequence`][Any type][Operation's argument]]
  1713. ]
  1714. [heading Expression Semantics]
  1715. __result_of_clear__<Sequence>::type
  1716. [*Return type]: A model of __forward_sequence__.
  1717. [*Semantics]: Returns an empty sequence.
  1718. [heading Complexity]
  1719. Constant.
  1720. [heading Header]
  1721. #include <boost/fusion/algorithm/transformation/clear.hpp>
  1722. #include <boost/fusion/include/clear.hpp>
  1723. [endsect]
  1724. [section erase]
  1725. Returns the result type of __erase__, given the input sequence and range delimiting iterator types.
  1726. [heading Description]
  1727. [heading Synopsis]
  1728. template<
  1729. typename Sequence,
  1730. typename It1,
  1731. typename It2 = __unspecified__>
  1732. struct erase
  1733. {
  1734. typedef __unspecified__ type;
  1735. };
  1736. [table Parameters
  1737. [[Parameter][Requirement][Description]]
  1738. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1739. [[`It1`][A model of __forward_iterator__][Operation's argument]]
  1740. [[`It2`][A model of __forward_iterator__][Operation's argument]]
  1741. ]
  1742. [heading Expression Semantics]
  1743. __result_of_erase__<Sequence, It1>::type
  1744. [*Return type]:
  1745. * A model of __forward_sequence__.
  1746. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1747. [*Semantics]: Returns a new sequence with the element at `It1` removed.
  1748. __result_of_erase__<Sequence, It1, It2>::type
  1749. [*Return type]: A model of __forward_sequence__.
  1750. [*Semantics]: Returns a new sequence with the elements between `It1` and `It2` removed.
  1751. [heading Complexity]
  1752. Constant.
  1753. [heading Header]
  1754. #include <boost/fusion/algorithm/transformation/erase.hpp>
  1755. #include <boost/fusion/include/erase.hpp>
  1756. [endsect]
  1757. [section erase_key]
  1758. [heading Description]
  1759. Returns the result type of __erase_key__, given the sequence and key types.
  1760. [heading Synopsis]
  1761. template<
  1762. typename Sequence,
  1763. typename Key
  1764. >
  1765. struct erase_key
  1766. {
  1767. typedef __unspecified__ type;
  1768. };
  1769. [table Parameters
  1770. [[Parameter][Requirement][Description]]
  1771. [[`Sequence`][A model of __forward_sequence__ and __associative_sequence__][Operation's argument]]
  1772. [[`Key`][Any type][Key type]]
  1773. ]
  1774. [heading Expression Semantics]
  1775. __result_of_erase_key__<Sequence, Key>::type
  1776. [*Return type]: A model of __forward_sequence__ and __associative_sequence__.
  1777. [*Semantics]: Returns a sequence with the elements of `Sequence`, except those with key `Key`.
  1778. [heading Complexity]
  1779. Constant.
  1780. [heading Header]
  1781. #include <boost/fusion/algorithm/transformation/erase_key.hpp>
  1782. #include <boost/fusion/include/erase_key.hpp>
  1783. [endsect]
  1784. [section insert]
  1785. [heading Description]
  1786. Returns the result type of __insert__, given the sequence, position iterator and insertion types.
  1787. [heading Synopsis]
  1788. template<
  1789. typename Sequence,
  1790. typename Position,
  1791. typename T
  1792. >
  1793. struct insert
  1794. {
  1795. typedef __unspecified__ type;
  1796. };
  1797. [table Parameters
  1798. [[Parameter][Requirement][Description]]
  1799. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1800. [[`Position`][A model of __forward_iterator__][Operation's argument]]
  1801. [[`T`][Any type][Operation's argument]]
  1802. ]
  1803. [heading Expression Semantics]
  1804. __result_of_insert__<Sequence, Position, T>::type
  1805. [*Return type]:
  1806. * A model of __forward_sequence__.
  1807. [*Semantics]: Returns a sequence with an element of type `T` inserted at position `Position` in `Sequence`.
  1808. [heading Complexity]
  1809. Constant.
  1810. [heading Header]
  1811. #include <boost/fusion/algorithm/transformation/insert.hpp>
  1812. #include <boost/fusion/include/insert.hpp>
  1813. [endsect]
  1814. [section insert_range]
  1815. [heading Description]
  1816. Returns the result type of __insert_range__, given the input sequence, position iterator and insertion range types.
  1817. [heading Synopsis]
  1818. template<
  1819. typename Sequence,
  1820. typename Position,
  1821. typename Range
  1822. >
  1823. struct insert_range
  1824. {
  1825. typedef __unspecified__ type;
  1826. };
  1827. [table Parameters
  1828. [[Parameter][Requirement][Description]]
  1829. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1830. [[`Position`][A model of __forward_iterator__][Operation's argument]]
  1831. [[`Range`][A model of __forward_sequence__][Operation's argument]]
  1832. ]
  1833. [heading Expression Semantics]
  1834. __result_of_insert_range__<Sequence, Position, Range>::type
  1835. [*Return type]:
  1836. * A model of __forward_sequence__.
  1837. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1838. [*Semantics]: Returns a sequence with the elements of `Range` inserted at position `Position` into `Sequence`.
  1839. [heading Complexity]
  1840. Constant.
  1841. [heading Header]
  1842. #include <boost/fusion/algorithm/transformation/insert_range.hpp>
  1843. #include <boost/fusion/include/insert_range.hpp>
  1844. [endsect]
  1845. [section join]
  1846. [heading Description]
  1847. Returns the result of joining 2 sequences, given the sequence types.
  1848. [heading Synopsis]
  1849. template<
  1850. typename LhSequence,
  1851. typename RhSequence
  1852. >
  1853. struct join
  1854. {
  1855. typedef __unspecified__ type;
  1856. };
  1857. [heading Expression Semantics]
  1858. __result_of_join__<LhSequence, RhSequence>::type
  1859. [*Return type]:
  1860. * A model of __forward_sequence__.
  1861. * A model of __associative_sequence__ if `LhSequence` and `RhSequence` implement the __associative_sequence__ model.
  1862. [*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.
  1863. [heading Complexity]
  1864. Constant.
  1865. [heading Header]
  1866. #include <boost/fusion/algorithm/transformation/join.hpp>
  1867. #include <boost/fusion/include/join.hpp>
  1868. [endsect]
  1869. [section zip]
  1870. [heading Description]
  1871. Zips sequences together to form a single sequence, whose members are tuples of the members of the component sequences.
  1872. [heading Synopsis]
  1873. template<
  1874. typename Sequence1,
  1875. typename Sequence2,
  1876. ...
  1877. typename SequenceN
  1878. >
  1879. struct zip
  1880. {
  1881. typedef __unspecified__ type;
  1882. };
  1883. [heading Expression Semantics]
  1884. __result_of_zip__<Sequence1, Sequence2, ... SequenceN>::type
  1885. [*Return type]: A model of the most restrictive traversal category of sequences `Sequence1` to `SequenceN`.
  1886. [*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'))`
  1887. [heading Complexity]
  1888. Constant.
  1889. [heading Header]
  1890. #include <boost/fusion/algorithm/transformation/zip.hpp>
  1891. #include <boost/fusion/include/zip.hpp>
  1892. [endsect]
  1893. [section pop_back]
  1894. [heading Description]
  1895. Returns the result type of __pop_back__, given the input sequence type.
  1896. [heading Synopsis]
  1897. template<
  1898. typename Sequence
  1899. >
  1900. struct pop_back
  1901. {
  1902. typedef __unspecified__ type;
  1903. };
  1904. [table Parameters
  1905. [[Parameter][Requirement][Description]]
  1906. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1907. ]
  1908. [heading Expression Semantics]
  1909. __result_of_pop_back__<Sequence>::type
  1910. [*Return type]:
  1911. * A model of __forward_sequence__.
  1912. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1913. [*Semantics]: Returns a sequence with all the elements of `Sequence` except the last element.
  1914. [heading Complexity]
  1915. Constant.
  1916. [heading Header]
  1917. #include <boost/fusion/algorithm/transformation/pop_back.hpp>
  1918. #include <boost/fusion/include/pop_back.hpp>
  1919. [endsect]
  1920. [section pop_front]
  1921. [heading Description]
  1922. Returns the result type of __pop_front__, given the input sequence type.
  1923. [heading Synopsis]
  1924. template<
  1925. typename Sequence
  1926. >
  1927. struct pop_front
  1928. {
  1929. typedef __unspecified__ type;
  1930. };
  1931. [table Parameters
  1932. [[Parameter][Requirement][Description]]
  1933. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1934. ]
  1935. [heading Expression Semantics]
  1936. __result_of_pop_front__<Sequence>::type
  1937. [*Return type]:
  1938. * A model of __forward_sequence__.
  1939. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
  1940. [*Semantics]: Returns a sequence with all the elements of `Sequence` except the first element.
  1941. [heading Complexity]
  1942. Constant.
  1943. [heading Header]
  1944. #include <boost/fusion/algorithm/transformation/pop_front.hpp>
  1945. #include <boost/fusion/include/pop_front.hpp>
  1946. [endsect]
  1947. [section push_back]
  1948. [heading Description]
  1949. Returns the result type of __push_back__, given the types of the input sequence and element to push.
  1950. [heading Synopsis]
  1951. template<
  1952. typename Sequence,
  1953. typename T
  1954. >
  1955. struct push_back
  1956. {
  1957. typedef __unspecified__ type;
  1958. };
  1959. [table Parameters
  1960. [[Parameter][Requirement][Description]]
  1961. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1962. [[`T`][Any type][Operation's argument]]
  1963. ]
  1964. [heading Expression Semantics]
  1965. __result_of_push_back__<Sequence, T>::type
  1966. [*Return type]:
  1967. * A model of __forward_sequence__.
  1968. [*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the end.
  1969. [heading Complexity]
  1970. Constant.
  1971. [heading Header]
  1972. #include <boost/fusion/algorithm/transformation/push_back.hpp>
  1973. #include <boost/fusion/include/push_back.hpp>
  1974. [endsect]
  1975. [section push_front]
  1976. [heading Description]
  1977. Returns the result type of __push_front__, given the types of the input sequence and element to push.
  1978. [heading Synopsis]
  1979. template<
  1980. typename Sequence,
  1981. typename T
  1982. >
  1983. struct push_front
  1984. {
  1985. typedef __unspecified__ type;
  1986. };
  1987. [table Parameters
  1988. [[Parameter][Requirement][Description]]
  1989. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  1990. [[`T`][Any type][Operation's argument]]
  1991. ]
  1992. [heading Expression Semantics]
  1993. __result_of_push_front__<Sequence, T>::type
  1994. [*Return type]:
  1995. * A model of __forward_sequence__.
  1996. [*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the beginning.
  1997. [heading Complexity]
  1998. Constant.
  1999. [heading Header]
  2000. #include <boost/fusion/algorithm/transformation/push_front.hpp>
  2001. #include <boost/fusion/include/push_front.hpp>
  2002. [endsect]
  2003. [section flatten]
  2004. [heading Description]
  2005. Returns the result type of __flatten__, given the input sequence type.
  2006. [heading Synopsis]
  2007. template<
  2008. typename Sequence
  2009. >
  2010. struct flatten
  2011. {
  2012. typedef __unspecified__ type;
  2013. };
  2014. [table Parameters
  2015. [[Parameter][Requirement][Description]]
  2016. [[`Sequence`][A model of __forward_sequence__][Operation's argument]]
  2017. ]
  2018. [heading Expression Semantics]
  2019. __result_of_flatten__<Sequence>::type
  2020. [*Return type]:
  2021. * A model of __forward_sequence__.
  2022. [*Semantics]: Returns a sequence with all the leaf elements of `Sequence`.
  2023. [heading Complexity]
  2024. Constant.
  2025. [heading Header]
  2026. #include <boost/fusion/algorithm/transformation/flatten.hpp>
  2027. #include <boost/fusion/include/flatten.hpp>
  2028. [endsect]
  2029. [endsect]
  2030. [endsect]
  2031. [endsect]