diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 00000000..c2c1c2f0 --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,16 @@ +project boost/libs/fusion/doc ; +import boostbook : boostbook ; +using quickbook ; + +boostbook quickbook + : + fusion.qbk + : + boost.root=../../../.. + boost.libraries=../../../libraries.htm + chunk.section.depth=4 + chunk.first.sections=1 + toc.section.depth=3 + toc.max.depth=1 + ; + diff --git a/doc/acknowledgements.qbk b/doc/acknowledgements.qbk new file mode 100644 index 00000000..ebd94d40 --- /dev/null +++ b/doc/acknowledgements.qbk @@ -0,0 +1,9 @@ +[section Acknowledgements] + +Special thanks to David Abrahams, Hartmut Kaiser, Aleksey Gurtovoy, Peder +Holt, Daniel Wallin, Jaakko Jarvi, Jeremiah Willcock, Dan Marsden, Eric +Niebler, Joao Abecasis. These people are instrumental in the design and +development of Fusion. + +[endsect] + diff --git a/doc/algorithms.qbk b/doc/algorithms.qbk new file mode 100644 index 00000000..519b8087 --- /dev/null +++ b/doc/algorithms.qbk @@ -0,0 +1,2415 @@ +[section Algorithms] +[heading Lazy Evaluation] + +Unlike __mpl__, Fusion algorithms are lazy and non sequence-type +preserving. What does that mean? It means that when you operate on a +sequence through a Fusion algorithm that returns a sequence, the sequence +returned may not be of the same class as the original. This is by design. +Runtime efficiency is given a high priority. Like __mpl__, and unlike +__stl__, fusion algorithms are functional in nature such that algorithms +are non mutating (no side effects). However, due to the high cost of +returning full sequences such as vectors and lists, /Views/ are returned +from Fusion algorithms instead. For example, the __transform__ algorithm +does not actually return a transformed version of the original sequence. +__transform__ returns a __transform_view__. This view holds a reference to +the original sequence plus the transform function. Iteration over the +__transform_view__ will apply the transform function over the sequence +elements on demand. This /lazy/ evaluation scheme allows us to chain as +many algorithms as we want without incurring a high runtime penalty. + +[heading Sequence Extension] + +The /lazy/ evaluation scheme where __algorithms__ return __views__ also +allows operations such as __push_back__ to be totally generic. In Fusion, +__push_back__ is actually a generic algorithm that works on all sequences. +Given an input sequence `s` and a value `x`, Fusion's __push_back__ +algorithm simply returns a __joint_view__: a view that holds a reference to +the original sequence `s` and the value `x`. Functions that were once +sequence specific and need to be implemented N times over N different +sequences are now implemented only once. That is to say that Fusion +sequences are cheaply extensible. However, an important caveat is that the +result of a sequence extending operation like __push_back__ does not retain +the properties of the original sequence such as associativity of __set__s. +To regain the original sequence, __conversion__ functions are provided. You +may use one of the __conversion__ functions to convert back to the original +sequence type. + +[heading Header] + #include + +[section Concepts] + +[section Polymorphic Function Object] + +[heading Description] + +A type of function object with a nested metafunction `result`. `result` +returns the result type of calling the function object, given the argument +types. + +[variablelist Notation + [[`F`][A Polymorphic Function Object type]] + [[`f`][A Polymorphic Function Object]] + [[`T1 ...TN`][Arbitrary types]] + [[`t1 ...tN`][Objects with types `T1 ...TN`]] +] + +[heading Refinement of] +__mpl_metafunction_class__ + +[heading Expression requirements] + +[table + [[Expression][Return Type][Runtime Complexity]] + [[`f(t1, ...tN)`][`F::result::type`][Unspecified]] +] + +[endsect] + +[endsect] + +[section Iteration] + +The iteration algorithms provide the fundamental algorithms for traversing +a sequence repeatedly applying an operation to its elements. + +[heading Header] + #include + +[section Functions] + +[section fold] + +[heading Description] +Repeatedly applies binary __poly_func_obj__ `f` to each element of a sequence and the previous state. + +[heading Synopsis] + template< + typename Sequence, + typename State, + typename F + > + typename __result_of_fold__::type fold( + Sequence& seq, State const& initial_state, F const& f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__,`f(e)` must be a valid expression for each element `e` in `seq`][Operation's argument]] + [[`initial_state`][Any type][Initial state]] + [[`f`][A model of binary __poly_func_obj__][Operation's argument]] +] + +[heading Expression Semantics] + fold(seq, initial_state, f); + +[*Return type]: Any type + +[*Semantics]: Equivalent to `f(eN ....f(e2,f(e1,initial_state)))` where `e1 ...eN` are the elements of `seq`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value` applications of `f`. + +[heading Header] + #include + +[heading Example] + struct make_string + { + template + struct apply + { + typedef std::string type; + }; + + template + std::string operator()(const T& t, const std::string& str) const + { + return str + boost::lexical_cast(t); + } + }; + ... + const __vector__ vec(1,2); + assert(__fold__(vec,std::string(""), make_string()) == "12"); + +[endsect] + +[section accumulate] + +[heading Description] +Repeatedly applies binary __poly_func_obj__ `f` to each element of a sequence and the previous state. +__accumulate__ is equivalent to __fold__. + +[heading Synopsis] + template< + typename Sequence, + typename State, + typename F + > + typename __result_of_accumulate__::type accumulate( + Sequence& seq, State const& initial_state, F const& f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__, `f(eN ....f(e2,f(e1,initial_state)))` must be a valid expression for each element `e1` to `eN` in `seq`][Operation's argument]] + [[`initial_state`][Any type][Initial state]] + [[`f`][A model of binary __poly_func_obj__][Operation's argument]] +] + +[heading Expression Semantics] + accumulate(seq, initial_state, f); + +[*Return type]: Any type + +[*Semantics]: Equivalent to `f(eN ....f(e2,f(e1,initial_state)))` where `e1 ...eN` are the elements of `seq`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value` applications of `f`. + +[heading Header] + #include + +[heading Example] + struct make_string + { + template + struct apply + { + typedef std::string type; + }; + + template + std::string operator()(const T& t, const std::string& str) const + { + return str + boost::lexical_cast(t); + } + }; + ... + const __vector__ vec(1,2); + assert(__accumulate__(vec,std::string(""), make_string()) == "12"); + +[endsect] + +[section for_each] + +[heading Description] +Applies a unary function object to each element of a sequence. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_for_each__::type for_each( + Sequence& seq, F const& f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__, `f(e)` must be a valid expression for each element `e` in `seq`][Operation's argument]] + [[`f`][A unary function object][Operation's argument]] +] + +[heading Expression Semantics] + __for_each__(seq, f); + +[*Return type]: `void` + +[*Semantics]: Calls `f(e)` for each element `e` in `seq`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value` applications of `f`. + +[heading Header] + #include + +[heading Example] + struct increment + { + template + void operator()(T& t) const + { + ++t; + } + }; + ... + __vector__ vec(1,2); + __for_each__(vec, increment()); + assert(vec == __make_vector__(2,3)); + +[endsect] + +[endsect] + +[section Metafunctions] + +[section fold] + +[heading Description] +Returns the result type of __fold__. + +[heading Synopsis] + template< + typename Sequence, + typename State, + typename F> + struct fold + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [The sequence to iterate]] + [[`State`] [Any type] [The initial state for the first application of `F`]] + [[`F`] [A model of binary __poly_func_obj__] [The operation to be applied on forward traversal]] +] + +[heading Expression Semantics] + __result_of_fold__::type + +[*Return type]: Any type + +[*Semantics]: Returns the result of applying `fold` to a sequence of type `Sequence`, with an initial state of +type `State` and binary __poly_func_obj__ of type `F`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value` applications of `F`. + +[heading Header] + #include + +[endsect] + +[section accumulate] + +[heading Description] +Returns the result type of __accumulate__. + +[heading Synopsis] + template< + typename Sequence, + typename State, + typename F> + struct accumulate + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [The sequence to iterate]] + [[`State`] [Any type] [The initial state for the first application of `F`]] + [[`F`] [A model of binary __poly_func_obj__] [The operation to be applied on forward traversal]] +] + +[heading Expression Semantics] + __result_of_accumulate__::type + +[*Return type]: Any type + +[*Semantics]: Returns the result of applying `accumulate` to a sequence of type `Sequence`, with an initial state of +type `State` and binary __poly_func_obj__ of type `F`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value` applications of `F`. + +[heading Header] + #include + +[endsect] + +[section for_each] +A metafunction returning the result type of applying __for_each__ to a sequence. The +return type of __for_each__ is always `void`. + +[heading Description] + +[heading Synopsis] + template< + typename Sequence, + typename F + > + struct for_each + { + typedef void type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`F`] [Any type] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_for_each__::type + +[*Return type]: `void`. + +[*Semantics]: Returns the return type of __for_each__ for a sequence of type `Sequence` and a unary function object `F`. +The return type is always `void`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[endsect] + +[endsect] + +[section Query] +The query algorithms provide support for searching and analyzing sequences. + +[heading Header] + #include + +[section Functions] + +[section any] + +[heading Description] +For a sequence `seq` and unary function object `f`, `any` returns true if `f` returns true for at least one element of `seq`. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_any__::type any( + Sequence const& seq, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`f`][A unary function object][The search predicate]] +] + +[heading Expression semantics] + __any__(seq, f); + +[*Return type]: `bool` + +[*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for some element `e` in `seq`. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + struct odd + { + template + bool operator()(T t) const + { + return t % 2; + } + }; + ... + assert(__any__(__make_vector__(1,2), odd())); + assert(!__any__(__make_vector__(2,4), odd())); + +[endsect] + +[section all] + +[heading Description] +For a sequence `seq` and unary function object `f`, `all` returns true if `f` returns true for every element of `seq`. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_all__::type all( + Sequence const& seq, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`f`][A unary function object][The search predicate]] +] + +[heading Expression Semantics] + __all__(seq, f); + +[*Return type]: `bool` + +[*Semantics]: Returns true if and only if `f(e)` evaluates to `true` for every element `e` in `seq`. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + struct odd + { + template + bool operator()(T t) const + { + return t % 2; + } + }; + ... + assert(__all__(__make_vector__(1,3), odd())); + assert(!__all__(__make_vector__(1,2), odd())); + +[endsect] + +[section none] + +[heading Description] +For a sequence `seq` and unary function object `f`, `none` returns true if `f` returns false for every element of `seq`. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_none__::type none( + Sequence const& seq, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`f`][A unary function object][The search predicate]] +] + +[heading Expression Semantics] + __none__(seq, f); + +[*Return type]: `bool` + +[*Semantics]: Returns true if and only if `f(e)` evaluates to `false` for every element `e` in `seq`. Result equivalent to `!any(seq, f)`. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + struct odd + { + template + bool operator()(T t) const + { + return t % 2; + } + }; + ... + assert(__none__(__make_vector__(2,4), odd())); + assert(!__none__(__make_vector__(1,2), odd())); + +[endsect] + +[section find] + +[heading Description] +Finds the first element of a given type within a sequence. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + __unspecified__ find(Sequence const& seq); + + template< + typename Sequence, + typename T + > + __unspecified__ find(Sequence& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][The sequence to search]] + [[`T`][Any type][The type to search for]] +] + +[heading Expression Semantics] + __find__(seq) + +[*Return type]: A model of the same iterator category as the iterators of `seq`. + +[*Semantics]: Returns an iterator to the first element of `seq` of type `T`, or `__end__(seq)` if there is no such element. +Equivalent to `__find_if__ >(seq)` + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + const __vector__ vec('a','0'); + assert(*__find__(vec) == '0'); + assert(__find__(vec) == __end__(vec)); + +[endsect] + +[section find_if] +Finds the first element within a sequence with a type for which a given __mpl_lambda_expression__ evaluates to +`boost::mpl::true_`. + +[heading Description] + +[heading Synopsis] + template< + typename Sequence, + typename F + > + __unspecified__ find_if(Sequence const& seq); + + template< + typename Sequence, + typename F + > + __unspecified__ find_if(Sequence& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][The sequence to search]] + [[`F`][A unary __mpl_lambda_expression__][The search predicate]] +] + +[heading Expression Semantics] + __find_if__(seq) + +[*Return type]: An iterator of the same iterator category as the iterators of `seq`. + +[*Semantics]: Returns the first element of `seq` for which __mpl_lambda_expression__ `F` evaluates to `boost::mpl::true_`, +or `__end__(seq)` if there is no such element. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1.0,2); + assert(*__find_if__ >(vec) == 2); + assert(__find_if__ >(vec) == __end__(vec)); + +[endsect] + +[section count] + +[heading Description] +Returns the number of elements of a given type within a sequence. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + typename __result_of_count__::type count( + Sequence const& seq, T const& t); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`T`][Any type][The type to count]] +] + +[heading Expression Semantics] + __count__(seq, t); + +[*Return type]: `int` + +[*Semantics]: Returns the number of elements of type `T` and equal to `t` in `seq`. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1.0,2,3); + assert(__count__(vec,2) == 1); + +[endsect] + +[section count_if] + +[heading Description] +Returns the number of elements within a sequence with a type for which a given unary function object evaluates to +`true`. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_count_if__::type count_if( + Sequence const& seq, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`f`][A unary function object][The search predicate]] +] + +[heading Expression Semantics] + __count_if__(seq, f) + +[*Return type]: `int` + +[*Semantics]: Returns the number of elements in `seq` where `f` evaluates to `true`. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2,3); + assert(__count_if__(vec,odd()) == 2); + +[endsect] + +[endsect] + +[section Metafunctions] + +[section any] + +[heading Description] +A metafunction returning the result type of __any__. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + struct any + { + typedef bool type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_any__::type + +[*Return type]: `bool`. + +[*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`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section all] + +[heading Description] +A metafunction returning the result type of __all__. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + struct all + { + typedef bool type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_all__::type + +[*Return type]: `bool`. + +[*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`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section none] + +[heading Description] +A metafunction returning the result type of __none__. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + struct none + { + typedef bool type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_none__::type + +[*Return type]: `bool`. + +[*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`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section find] + +[heading Description] +Returns the result type of `find`, given the sequence and search types. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct find + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [Model of __forward_sequence__] [Operation's argument]] + [[`T`] [Any type] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_find__::type + +[*Return type]: A model of the same iterator category as the iterators of `Sequence`. + +[*Semantics]: Returns an iterator to the first element of type `T` in `Sequence`, or `__result_of_end__::type` if there is no such element. + +[heading Complexity] +Linear, at most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[endsect] + +[section find_if] + +[heading Description] +Returns the result type of `find_if` given the sequence and predicate types. + +[heading Synopsis] + template< + typename Sequence, + typename Pred + > + struct find_if + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`Pred`] [A model of __mpl_lambda_expression__] [Operation's arguments]] +] + +[heading Expression Semantics] + __result_of_find_if__::type + +[*Return type]: A model of the same iterator category as the iterators of `Sequence`. + +[*Semantics]: Returns an iterator to the first element in `Sequence` for which `Pred` evaluates to true. Returns `__result_of_end__::type` if there is no such element. + +[heading Complexity] +Linear. At most `__result_of_size__::value` comparisons. + +[heading Header] + #include + +[endsect] + +[section count] + +[heading Description] +A metafunction that returns the result type of `count` given the sequence and search types. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct count + { + typedef int type; + }; + +[table Parameters + [[Parameter] [Requirement] [heading Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`T`] [Any type] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_count__::type + +[*Return type]: `int`. + +[*Semantics]: Returns the return type of __count__. The return type is always `int`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section count_if] + +[heading Description] +A metafunction that returns the result type of `count_if` given the sequence and predicate types. + +[heading Synopsis] + template< + typename Sequence, + typename Pred + > + struct count_if + { + typedef int type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] + [[`Pred`] [A unary function object] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_count_if__::type + +[*Return type]: `int`. + +[*Semantics]: Returns the return type of __count_if__. The return type is always `int`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[endsect] + +[endsect] + +[section Transformation] +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. + +[note As the transformation algorithms return views onto their input arguments, +it is important that the lifetime of the input arguments is greater than the +period during which you wish to use the results.] + +[heading Header] + #include + +[section Functions] + +[section filter] + +[heading Description] +For a given sequence, filter returns a new sequences containing only the elements of a specified type. + +[heading Synopsis] + template< + typename T, + typename Sequence + > + typename __result_of_filter__::type filter(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][The type to retain]] +] + +[heading Expression Semantics] + __filter__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing all the elements of `seq` of type `T`. +Equivalent to `__filter_if__ >(seq)`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2,3,4); + assert(__filter__(vec) == __make_vector__(1,2)); + +[endsect] + +[section filter_if] + +[heading Description] +For a given sequence, __filter_if__ returns a new sequences containing +only the elements with types for which a given __mpl_lambda_expression__ evaluates to `boost::mpl::true_`. + +[heading Synopsis] + template< + typename Pred, + typename Sequence + > + typename __result_of_filter_if__::type filter_if(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`Pred`][A unary __mpl_lambda_expression__][The predicate to filter by]] +] + +[heading Expression Semantics] + __filter_if__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing all the elements of `seq` with types for which `Pred` evaluates +to `boost::mpl::true_`. The order of the retained elements is the same as in the original sequence. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2,3.0,4.0); + assert(__filter_if__ >(vec) == __make_vector__(1,2)); + +[endsect] + +[section transform] + +[heading Description] +For a sequence `seq` and __poly_func_obj__ `F`, `transform` returns a new sequence +with elements created by applying `F` to each element of `seq`. + +[heading Unary version synopsis] + template< + typename Sequence, + typename F + > + typename __result_of_transform__::type transform( + Sequence const& seq, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`f`][A model of unary __poly_func_obj__ where `f(e)` is a valid expression for each element `e` of `seq`][Transformation function]] +] + +[heading Expression Semantics] + __transform__(seq, f); + +[*Return type]: A model of __forward_sequence__ + +[*Semantics]: Returns a new sequence, containing the return values of `f(e)` for each element `e` within `seq`. + +[heading Binary version synopsis] + template< + typename Sequence1, + typename Sequence2, + typename F + > + typename __result_of_transform__::type transform( + Sequence1 const& seq1, Sequence2 const& seq2, F f); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq1`][A model of __forward_sequence__][Operation's argument]] + [[`seq2`][A model of __forward_sequence__][Operation's argument]] + [[`f`][A model of binary __poly_func_obj__ where `f(e1, e2)` is a valid expression for each pair of elements `e1` and `e2` of `seq1` and `seq2` respectively][Transformation function]] +] + +[*Return type]: A model of __forward_sequence__. + +[*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. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + struct triple + { + template + struct apply + { + typedef T type; + }; + + template + T operator()(T t) const + { + return t * 3; + }; + }; + ... + assert(__transform__(__make_vector__(1,2,3), triple()) == __make_vector__(3,6,9)); + +[endsect] + +[section replace] + +[heading Description] +Replaces each value within a sequence of a given type and value with a new value. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + typename __result_of_replace__::type replace( + Sequence const& seq, T const& old_value, T const& new_value); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`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]] + [[`old_value`][Any type][Value to replace]] + [[`new_value`][Any type][Replacement value]] +] + +[heading Expression Semantics] + __replace__(seq, old_value, new_value); + +[*Return type]: A model of __forward_sequence__. + +[*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`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__replace__(__make_vector__(1,2), 2, 3) == __make_vector__(1,3)); + +[endsect] + +[section replace_if] + +[heading Description] +Replaces each element of a given sequence for which an unary function object evaluates to `true` replaced with +a new value. + +[heading Synopsis] + template< + typename Sequence, + typename F, + typename T> + typename __result_of_replace_if__::type replace_if( + Sequence const& seq, F f, T const& new_value); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`f`][A function object for which `f(e)` is a valid expression, convertible to `bool`, for each element `e` in `seq`][Operation's argument]] + [[`new_value`][Any type][Replacement value]] +] + +[heading Expression Semantics] + __replace_if__(seq, f, new_value); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence with all the elements of `seq`, +with `new_value` assigned to each element for which `f` evaluates to `true`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + struct odd + { + template + bool operator()(T t) const + { + return t % 2; + } + }; + ... + assert(__replace_if__(__make_vector__(1,2), odd(), 3) == __make_vector__(3,2)); + +[endsect] + +[section remove] + +[heading Description] +Returns a new sequence, with all the elements of the original sequence, except those of a given type. + +[heading Synopsis] + template< + typename T, + typename Sequence + > + typename __result_of_remove__::type replace(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][Type to remove]] +] + +[heading Expression Semantics] + __remove__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except +those of type `T`. Equivalent to `__remove_if__ >(seq)`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2.0); + assert(__remove__(vec) == __make_vector__(1)); + +[endsect] + +[section remove_if] + +[heading Description] +Returns a new sequence, containing all the elements of the original except those where a given unary +function object evaluates to `true`. + +[heading Synopsis] + template< + typename Pred, + typename Sequence + > + typename __result_of_remove_if__::type remove_if(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`Pred`][A model of unary __mpl_lambda_expression__][Removal predicate]] +] + +[heading Expression Semantics] + __remove_if__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, except +those elements with types for which `Pred` evaluates to `boost::mpl::true_`. +Equivalent to `__filter__ >(seq)`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2.0); + assert(__remove_if__ >(vec) == __make_vector__(1)); + +[endsect] + +[section reverse] + +[heading Description] +Returns a new sequence with the elements of the original in reverse order. + +[heading Synposis] + template< + typename Sequence + > + typename __result_of_reverse__::type reverse(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __bidirectional_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __reverse__(seq); + +[*Return type]: A model of __bidirectional_sequence__. + +[*Semantics]: Returns a new sequence containing all the elements of `seq` in reverse order. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__reverse__(__make_vector__(1,2,3)) == __make_vector__(3,2,1)); + +[endsect] + +[section clear] + +[heading Description] +__clear__ returns an empty sequence. + +[heading Synposis] + template< + typename Sequence + > + typename __result_of_clear__::type clear(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __clear__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Expression Semantics]: Returns a sequence with no elements. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[heading Example] + assert(__clear__(__make_vector__(1,2,3)) == __make_vector__()); + +[endsect] + +[section erase] + +[heading Description] +Returns a new sequence, containing all the elements of the original except those at a specified iterator, or +between two iterators. + +[heading Synposis] + template< + typename Sequence, + typename First + > + typename __result_of_erase__::type erase( + Sequence const& seq, First const& it1); + + template< + typename Sequence, + typename First, + typename Last + > + typename __result_of_erase__::type erase( + Sequence const& seq, First const& it1, Last const& it2); + +[table Parameters + [[Parameters][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`it1`][A model of __forward_iterator__][Iterator into `seq`]] + [[`it2`][A model of __forward_iterator__][Iterator into `seq` after `it1`]] +] + +[heading Expression Semantics] + __erase__(seq, pos); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq` except the element at `pos`. + + __erase__(seq, first, last); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, with all the elements of `seq`, in their original order, except those +in the range [`first`,`last`). + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1, 2.0, 'c'); + assert(__erase__(vec, __next__(__begin__(vec))) == __make_vector__(1, 'c')); + assert(__erase__(vec, __next__(__begin__(vec)), __end__(vec)) == __make_vector__(1)); + +[endsect] + +[section erase_key] + +[heading Description] +For an __associative_sequence__ `seq`, returns a __forward_sequence__ containing all the +elements of the original except those with a given key. + +[heading Synposis] + template< + typename Key, + typename Sequence + > + typename result_of::erase_key::type erase_key(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __associative_sequence__][Operation's argument]] + [[`Key`][Any type][Key to erase]] +] + +[heading Expression Semantics] + __erase_key__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq`, except those with key `Key`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__erase_key__(__make_map__('a', 'b')) == __make_map__('b')); + +[endsect] + +[section insert] + +[heading Description] +Returns a new sequence with all the elements of the original, an a new element inserted the +position described by a given iterator. + +[heading Synposis] + template< + typename Sequence, + typename Pos, + typename T + > + __unspecified__ insert(Sequence const& seq, Pos const& pos, T const& t); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`pos`][A model of __forward_iterator__][The position to insert at]] + [[`t`][Any type][The value to insert]] +] + +[heading Expression Semantics] + __insert__(seq, p, t); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq`, in their original order, and a new element with the +type and value of `t` inserted at iterator `pos`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2); + assert(__insert__(vec, __next__(__begin__(vec)), 3) == __make_vector__(1,3,2)); + +[endsect] + +[section insert_range] + +[heading Description] +Returns a new sequence with another sequence inserted at a specified iterator. + +[heading Synposis] + template< + typename Sequence, + typename Pos, + typename Range + > + typename __result_of_insert_range__::type insert_range( + Sequence const& seq, Pos const& pos, Range const& range); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`pos`][A model of __forward_iterator__][The position to insert at]] + [[`range`][A model of __forward_sequence__][Range to insert]] +] + +[heading Expression Semantics] + __insert__(seq, pos, range); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence, containing all the elements of `seq`, and the elements of +`range` inserted at iterator `pos`. All elements retaining their ordering from the orignal sequences. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + const __vector__ vec(1,2); + assert(__insert_range__(vec, __next__(__begin__(vec)), __make_vector__(3,4)) == __make_vector__(1,3,4,2)); + +[endsect] + +[section join] + +[heading Description] +Takes 2 sequences and returns a sequence containing the elements of the first followed by the elements of the second. + +[heading Synopsis] + template< + typename LhSequence, + typename RhSequence> + typename __result_of_join__::type join(LhSequence const& lhs, RhSequence const& rhs); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`lhs`][A model of __forward_sequence__][Operation's argument]] + [[`rhs`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __join__(lhs, rhs); + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing all the elements of `lhs` followed by all the elements of `rhs`. The order of th elements is preserved. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + __vector__ v1(1, 'a'); + __vector__ v2(2, 'b'); + assert(__join__(v1, v2) == __make_vector__(1,'a',2,'b')); + +[endsect] + +[section zip] + +[heading Description] +Zips sequences together to form a single sequence, whos members are tuples of the members of the component sequences. + +[heading Synopsis] + template< + typename Sequence1, + typename Sequence2, + ... + typename SequenceN + > + typename __result_of_zip__::type + zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq1` to `seqN`][Each sequence is a model of __forward_sequence__.][Operation's argument]] +] + +[heading Expression Semantics] + __zip__(seq1, seq2, ... seqN); + +[*Return type]: A model of __forward_sequence__. + +[*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'))` + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + __vector__ v1(1, 'a'); + __vector__ v2(2, 'b'); + assert(__zip__(v1, v2) == __make_vector__(__make_vector__(1, 2),__make_vector__('a', 'b')); + +[endsect] + +[section pop_back] + +[heading Description] +Returns a new sequence, with the last element of the original removed. + +[heading Synopsis] + template< + typename Sequence + > + typename __result_of_pop_back__::type pop_back(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __pop_back__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*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`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(___pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); + +[endsect] + +[section pop_front] + +[heading Description] +Returns a new sequence, with the first element of the original removed. + +[heading Synopsis] + template< + typename Sequence + > + typename __result_of_pop_front__::type pop_front(Sequence const& seq); + + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __pop_front__(seq); + +[*Return type]: A model of __forward_sequence__. + +[*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`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__pop_front__(__make_vector__(1,2,3)) == __make_vector__(2,3)); + +[endsect] + +[section push_back] + +[heading Description] +Returns a new sequence with an element added at the end. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + typename __result_of_push_back__::type push_back( + Sequence const& seq, T const& t); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`t`][Any type][The value to add to the end]] +] + +[heading Expression Semantics] + __push_back__(seq, t); + +[*Return type]: A model of __forward_sequence__. + +[*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`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__push_back__(__make_vector__(1,2,3),4) == __make_vector__(1,2,3,4)); + +[endsect] + +[section push_front] + +[heading Description] +Returns a new sequence with an element added at the beginning. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + typename __result_of_push_front__::type push_front( + Sequence const& seq, T const& t); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] + [[`t`][Any type][The value to add to the beginning]] +] + +[heading Expression Semantics] + __push_back__(seq, t); + +[*Return type]: A model of __forward_sequence__. + +[*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`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + #include + +[heading Example] + assert(__push_front__(__make_vector__(1,2,3),0) == __make_vector__(0,1,2,3)); + +[endsect] + +[endsect] + +[section Metafunctions] + +[section filter] + +[heading Description] +Returns the result type of __filter__ given the sequence type and type to retain. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct filter + { + typedef __unspecified__ type; + }; + +[table Parameter + [[Parameter] [Requirement] [Description]] + [[`Sequence`][A model of __forward_sequence__] [Operation's argument]] + [[`T`][Any type][Type to retain]] +] + +[heading Expression Semantics] + __result_of_filter__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing the elements of `Sequence` that are of type `T`. Equivalent to `__result_of_filter_if__ >::type`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section filter_if] + +[heading Description] +Returns the result type of __filter_if__ given the sequence and unary __mpl_lambda_expression__ predicate type. + +[heading Synopsis] + template< + typename Sequence, + typename Pred + > + struct filter_if + { + typedef __unspecified__ type; + }; + +[table Parameter + [[Parameter] [Requirement] [Description]] + [[`Sequence`][A model of __forward_sequence__] [Operation's argument]] + [[`Pred`][A unary __mpl_lambda_expression__][Type to retain]] +] + +[heading Expression Semantics] + __result_of_filter_if__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::true_`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section transform] + +[heading Description] +Returns the result of type __transform__, given the sequence and __poly_func_obj__ types. + +[heading Synopsis] + template< + typename Sequence, + typename F + > + struct transform + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A model of __forward_sequence__ ][Operation's argument]] + [[`F`] [A model of unary __poly_func_obj__][Transformation function object]] +] + +[heading Expression Semantics] + __result_of_transform__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with values `F::apply::type` for each element type `E` in `Sequence`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section replace] + +[heading Description] +Returns the result type of __replace__, given the types of the input sequence and element to replace. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct replace + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][The type of the search and replacement objects]] +] + +[heading Expression Semantics] + __result_of_replace__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns the return type of __replace__. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section replace_if] + +[heading Description] +Returns the result type of __replace_if__, given the types of the sequence, __poly_func_obj__ predicate and replacement object. + +[heading Synopsis] + template< + typename Sequence, + typename F, + typename T> + struct replace_if + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`F`][A model of unary __poly_func_obj__][Replacement predicate]] + [[`T`][Any type][The type of the replacement object]] +] + +[heading Expression Semantics] + __result_of_replace_if__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns the return type of __replace_if__. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section remove] + +[heading Description] +Returns the result type of __remove__, given the sequence and removal types. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct remove + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][Remove elements of this type]] +] + +[heading Expression Semantics] + __result_of_remove__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_replace_if__ >::type`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section remove_if] + +[heading Description] +Returns the result type of __remove_if__, given the input sequence and unary __mpl_lambda_expression__ predicate types. + +[heading Synopsis] + template< + typename Sequence, + typename Pred + > + struct remove_if + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`Pred`][A model of unary __mpl_lambda_expression__][Remove elements which evaluate to `boost::mpl::true_`]] +] + +[heading Expression Semantics] + __result_of_remove_if__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence containing the elements of `Sequence` for which `Pred` evaluates to `boost::mpl::false_`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section reverse] + +[heading Description] +Returns the result type of __reverse__, given the input sequence type. + +[heading Synopsis] + template< + typename Sequence + > + struct reverse + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __bidirectional_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_reverse__::type + +[*Return type]: A model of __bidirectional_sequence__. + +[*Semantics]: Returns a sequence with the elements in the reverse order to `Sequence`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section clear] + +[heading Description] +Returns the result type of __clear__, given the input sequence type. + +[heading Synopsis] + template< + typename Sequence + > + struct clear + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][Any type][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_clear__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns an empty sequence. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section erase] +Returns the result type of __erase__, given the input sequence and range delimiting iterator types. + +[heading Description] + +[heading Synopsis] + template< + typename Sequence, + typename It1, + typename It2 = __unspecified__> + struct erase + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`It1`][A model of __forward_iterator__][Operation's argument]] + [[`It2`][A model of __forward_iterator__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_erase__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence with the element at `It1` removed. + + __result_of_erase__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence with the elements between `It1` and `It2` removed. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section erase_key] + +[heading Description] +Returns the result type of __erase_key__, given the sequence and key types. + +[heading Synopsis] + template< + typename Sequence, + typename Key + > + struct erase_key + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __associative_sequence__][Operation's argument]] + [[`Key`][Any type][Key type]] +] + +[heading Expression Semantics] + __result_of_erase_key__::type + +[*Return type]: A model of __associative_sequence__. + +[*Semantics]: Returns a sequence with the elements of `Sequence`, except those with key `Key`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section insert] + +[heading Description] +Returns the result type of __insert__, given the sequence, position iterator and insertion types. + +[heading Synopsis] + template< + typename Sequence, + typename Position, + typename T + > + struct insert + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`Position`][A model of __forward_iterator__][Operation's argument]] + [[`T`][Any type][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_insert__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with an element of type `T` inserted at position `Position` in `Sequence`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section insert_range] + +[heading Description] +Returns the result type of __insert_range__, given the input sequence, position iterator and insertion range types. + +[heading Synopsis] + template< + typename Sequence, + typename Position, + typename Range + > + struct insert_range + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`Position`][A model of __forward_iterator__][Operation's argument]] + [[`Range`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_insert_range__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with the elements of `Range` inserted at position `Position` into `Sequence`. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section join] + +[heading Description] +Returns the result of joining 2 sequences, given the sequence types. + +[heading Synopsis] + template< + typename LhSequence, + typename RhSequence + > + struct join + { + typedef __unspecified__ type; + }; + +[heading Expression Semantics] + __result_of_join__::type + +[*Return type]: A model of __forward_sequence__. + +[*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. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section zip] + +[heading Description] +Zips sequences together to form a single sequence, whos members are tuples of the members of the component sequences. + +[heading Synopsis] + template< + typename Sequence1, + typename Sequence2, + ... + typename SequenceN + > + struct zip + { + typedef __unspecified__ type; + }; + +[heading Expression Semantics] + __result_of_zip__::type + +[*Return type]: A model of the most restrictive traversal category of sequences `Sequence1` to `SequenceN`. + +[*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'))` + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section pop_back] + +[heading Description] +Returns the result type of __pop_back__, given the input sequence type. + +[heading Synopsis] + template< + typename Sequence + > + struct pop_back + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_pop_back__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with all the elements of `Sequence` except the last element. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section pop_front] + +[heading Description] +Returns the result type of __pop_front__, given the input sequence type. + +[heading Synopsis] + template< + typename Sequence + > + struct pop_front + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_pop_front__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with all the elements of `Sequence` except the first element. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section push_back] + +[heading Description] +Returns the result type of __push_back__, given the types of the input sequence and element to push. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct push_back + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_push_back__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the end. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[section push_front] + +[heading Description] +Returns the result type of __push_front__, given the types of the input sequence and element to push. + +[heading Synopsis] + template< + typename Sequence, + typename T + > + struct push_front + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`T`][Any type][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_push_front__::type + +[*Return type]: A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with the elements of `Sequence` and an element of type `T` added to the beginning. + +[heading Complexity] +Constant. + +[heading Header] + #include + +[endsect] + +[endsect] + +[endsect] + +[endsect] \ No newline at end of file diff --git a/doc/changelog.qbk b/doc/changelog.qbk new file mode 100644 index 00000000..aa030033 --- /dev/null +++ b/doc/changelog.qbk @@ -0,0 +1,3 @@ +[section Change log] +This section summarizes significant changes to the Fusion library. +[endsect] \ No newline at end of file diff --git a/doc/extension.qbk b/doc/extension.qbk new file mode 100644 index 00000000..f422c8fa --- /dev/null +++ b/doc/extension.qbk @@ -0,0 +1,398 @@ +[section Extension] + +The Fusion library is designed to be extensible, new sequences types can easily +be added. In fact, the library support for `std::pair`, `boost::array` and __mpl__ +sequences is entirely provided using the extension mechanism. + +The process for adding a new sequence type to Fusion is: + +# Enable the __tag_dispatching__ mechanism used by Fusion for your sequence type +# Design an iterator type for the sequence +# Provide specialized behaviour for the intrinsic operations of the new Fusion sequence + +[heading Our example] + +In order to illustrate enabling a new sequence type for use with Fusion, we +are going to use the type: + + namespace example + { + struct example_struct + { + std::string name; + int age; + example_struct( + const std::string& n, + int a) + : name(n), age(a) + {} + }; + } + +We are going to pretend that this type has been provided by a 3rd party +library, and therefore cannot be modified. We shall work through all the +necessary steps to enable `example_struct` to serve as an __associative_sequence__ +as described in the __quick_start__ guide. + +[heading Enabling Tag Dispatching] + +The Fusion extensibility mechanism uses __tag_dispatching__ to call the +correct code for a given sequence type. In order to exploit the tag +dispatching mechanism we must first declare a new tag type for the +mechanism to use. For example: + + namespace boost { namespace fusion { + struct example_sequence_tag; // Only definition needed + }} + +Next we need to enable the `traits::tag_of` metafunction to return our newly chosen +tag type for operations involving our sequence. This is done by specializing +`traits::tag_of` for our sequence type. + + #include + + namespace boost { namespace fusion { namespace traits { + + template<> + struct tag_of + { + typedef example_sequence_tag type; + }; + }}} + +`traits::tag_of` also has a second template argument, +that can be used in conjuction with `boost::enable_if` to provide tag +support for whole clases of types. This feature is not necessary +for our sequence, but for an example see the code in: + + #include + +[heading Designing a suitable iterator] + +We need an iterator to describe positions, and provide access to +the data within our sequence. As it is straightforward to do, +we are going to provide a random access iterator in our example. + +We will use a simple design, in which the 2 members of +`example_struct` are given numbered indices, 0 for `name` and +1 for `age` respectively. + + template + struct example_struct_iterator + : iterator_base > + { + BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3); + typedef Struct struct_type; + typedef mpl::int_ index; + typedef random_access_traversal_tag category; + + example_struct_iterator(Struct& str) + : struct_(str) {} + + Struct& struct_; + }; + +A quick summary of the details of our iterator: + +# The iterator is parameterized by the type it is iterating over, and the index of the current element. +# The typedefs `struct_type` and `index` provide convenient access to information we will need later in + the implementation. +# The typedef `category` allows the `traits::__category_of__` metafunction to establish + the traversal category of the iterator. +# The constructor stores a reference to the `example_struct` being iterated over. + +We also need to enable __tag_dispatching__ for our iterator type, with another specialization of +`traits::tag_of`: + + namespace boost { namespace fusion { + struct example_struct_iterator_tag; + + namespace traits + { + template + struct tag_of > + { + typedef example_struct_iterator_tag type; + }; + } + }} + +In isolation, the iterator implementation is pretty dry. Things should become clearer as we +add features to our implementation. + +[heading A first couple of instructive features] + +To start with, we will get the __result_of_value_of__ metafunction working. To +do this, we provide a specialization of the `boost::fusion::extension::value_of_impl` template for +our iterator's tag type. + + template<> + struct value_of_impl + { + template + struct apply; + + template + struct apply > + { + typedef std::string type; + }; + + template + struct apply > + { + typedef int type; + }; + }; + +The implementation itself is pretty simple, it just uses 2 partial specializations to +provide the type of the 2 different members of `example_struct`, based on the index of the iterator. + +To understand how `value_of_impl` is used by the library we will look at the implementation of __value_of__: + + template + struct __value_of__ + { + typedef typename + extension::value_of_impl:: + template apply::type + type; + }; + +So __value_of__ uses __tag_dispatching__ to select an __mpl_metafunction_class__ +to provide its functionality. You will notice this pattern throughout the +implementation of Fusion. + +Ok, lets enable dereferencing of our iterator. In this case we must provide a suitable +specialization of `deref_impl`. + + template<> + struct deref_impl + { + template + struct apply; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, std::string const&, std::string&>::type type; + + static type + call(example_struct_iterator const& it) + { + return it.struct_.name; + } + }; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, int const&, int&>::type type; + + static type + call(example_struct_iterator const& it) + { + return it.struct_.age; + } + }; + }; + +The use of `deref_impl` is very similar to that of `value_of_impl`, but it also +provides some runtime functionality this time via the `call` static member function. +To see how `deref_impl` is used, lets have a look at the implementation of __deref__: + + namespace result_of + { + template + struct __deref__ + { + typedef typename + deref_impl:: + template apply::type + type; + }; + } + + template + typename __result_of_deref__::type + __deref__(Iterator const& i) + { + typename __result_of_deref__::type result = + extension::deref_impl:: + template apply::call(i); + return result; + } + +So again __result_of_deref__ uses __tag_dispatching__ in exactly the +same way as the __value_of__ implementation. The runtime functionality used +by __deref__ is provided by the `call` static function of the selected +__mpl_metafunction_class__. + +The actual implementation of `deref_impl` is slightly more complex than that of `value_of_impl`. +We also need to implement the `call` function, which returns a reference +to the appropriate member of the underlying sequence. We also require a little +bit of metaprogramming to return `const` references if the underlying sequence +is const. + +[note Although there is a fair amount of left to do to produce a fully fledged +Fusion sequence, __value_of__ and __deref__ illustrate all the signficant concepts +required. The remainder of the process is very repetitive, simply requiring +implementation of a suitable `xxxx_impl` for each feature `xxxx`. +] + +[heading Implementing the remaining iterator functionality] + +Ok, now we have seen the way __value_of__ and __deref__ work, everything else will work + in pretty much the same way. Lets start with forward iteration, +by providing a `next_impl`: + + template<> + struct next_impl + { + template + struct apply + { + typedef typename Iterator::struct_type struct_type; + typedef typename Iterator::index index; + typedef example_struct_iterator type; + + static type + call(Iterator const& i) + { + return type(i.struct_); + } + }; + }; + +This should be very familiar from our `deref_impl` implementation, we will be +using this approach again and again now. Our design is simply to increment +the `index` counter to move on to the next element. The various other iterator +manipulations we need to perform will all just involve simple calculations +with the `index` variables. + +We also need to provide a suitable `equal_to_impl` so that iterators can be +correctly compared. A __bidirectional_iterator__ will also need an implementation of `prior_impl`. For a +__random_access_iterator__ `distance_impl` and `advance_impl` also need to be provided +in order to satisfy the necessary complexity guarantees. As our iterator is +a __random_access_iterator__ we will have to implement all of these functions. + +Full implementations of `prior_impl`, `advance_impl`, `distance_impl` and `equal_to_impl` are +provided in the example code. + +[heading Implementing the intrinsic functions of the sequence] + +In order that Fusion can correctly identify our sequence as a Fusion sequence, we +need to enable `is_sequence` for our sequence type. As usual we just create +an `impl` type specialized for our sequence tag: + + template<> + struct is_sequence_impl + { + template + struct apply : mpl::true_ {}; + }; + +We've some similar formalities to complete, providing `category_of_impl` so Fusion +can correctly identify our sequence type, and `is_view_impl` so Fusion can correctly +identify our sequence as not being a __view__ type. Implementations are +provide in the example code. + +Now we've completed some formalities, on to more interesting features. Lets get +__begin__ working so that we can get an iterator to start accessing the data in +our sequence. + + template<> + struct begin_impl + { + template + struct apply + { + typedef example_struct_iterator type; + + static type + call(Sequence& seq) + { + return type(seq); + } + }; + }; + +The implementation uses the same ideas we have applied throughout, in this case +we are just creating one of the iterators we developed earlier, pointing to the +first element in the sequence. The implementation of __end__ is very similar, and +is provided in the example code. + +For our __random_access_sequence__ we will also need to implement `size_impl`, +`value_at_impl` and `at_impl`. + +[heading Enabling our type as an associative container] + +In order for `example_struct` to serve as an associative container, +we need to enable 3 lookup features, __at_key__, __value_at_key__ and __has_key__. +We also need to provide an implementation of the `is_associative` trait +so that our sequence can be correctly identified as an associative container. + +To implement `at_key_impl` we need to associate the `fields::age` and `fields::age` +types described in the __quick_start__ guide with the appropriate members of `example_struct`. +Our implementation is as follows: + + template<> + struct at_key_impl + { + template + struct apply; + + template + struct apply + { + typedef typename mpl::if_< + is_const, + std::string const&, + std::string&>::type type; + + static type + call(Sequence& seq) + { + return seq.name; + }; + }; + + template + struct apply + { + typedef typename mpl::if_< + is_const, + int const&, + int&>::type type; + + static type + call(Sequence& seq) + { + return seq.age; + }; + }; + }; + +Its all very similar to the implementations we've seen previously, +such as `deref_impl` and `value_of_impl`. Instead of identifying +the members by index or position, we are now selecting them using +the types `fields::name` and `fields::age`. The implementations of +`value_at_key_impl` and `has_key_impl` are equally straightforward, +and are provided in the example code, along with an implementation +of `is_associative_impl`. + +[heading Summary] + +We've now worked through the entire process for adding a new random +access sequence and we've also enabled our type to serve as an associative +container. The implementation was slightly longwinded, but followed +a simple repeating pattern. + +The support for `std::pair`, __mpl__ sequences, and `boost::array` all +use the same approach, and provide additional examples of the approach +for a variety of types. + +[endsect] + diff --git a/doc/fusion.qbk b/doc/fusion.qbk new file mode 100644 index 00000000..72b8d50a --- /dev/null +++ b/doc/fusion.qbk @@ -0,0 +1,263 @@ +[library Fusion + [quickbook 1.3] + [version 2.0] + [authors [de Guzman, Joel], [Marsden, Dan]] + [copyright 2001 2002 2003 2004 2005 Joel de Guzman, Dan Marsden] + [purpose Statically Typed Heterogeneous Data Structures and Algorithms] + [license + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + [@http://www.boost.org/LICENSE_1_0.txt]) + ] +] + +[def __note__ [$images/note.png]] +[def __alert__ [$images/alert.png]] +[def __tip__ [$images/tip.png]] +[def __caution__ [$images/caution.png]] + +[def __spirit__ [@http://spirit.sourceforge.net Spirit]] +[def __phoenix__ [@http://boost.org/libs/spirit/phoenix/index.html Phoenix]] +[def __mpl__ [@http://www.boost.org/libs/mpl/index.html MPL]] +[def __stl__ [@http://en.wikipedia.org/wiki/Standard_Template_Library STL]] +[def __tuple__ [@http://www.boost.org/libs/tuple/doc/tuple_users_guide.html Boost.Tuple]] +[def __tr1__tuple__ [@http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1403.pdf TR1 Tuple]] +[def __boost_tools__ [@http://www.boost.org/tools/index.html Boost Tools]] +[def __spirit_list__ [@https://lists.sourceforge.net/lists/listinfo/spirit-general Spirit Mailing List]] +[def __spirit_general__ [@news://news.gmane.org/gmane.comp.spirit.general Spirit General NNTP news portal]] +[def __gmane__ [@http://www.gmane.org Gmane]] +[def __mlist_archive__ [@http://news.gmane.org/gmane.comp.parsers.spirit.general]] +[def __jaakko_jarvi__ [@http://www.boost.org/people/jaakko_jarvi.htm Jaakko Jarvi]] +[def __david_abrahams__ [@http://www.boost.org/people/dave_abrahams.htm David Abrahams]] +[def __boost_any__ [@http://boost.org/doc/html/any.html Boost.Any]] +[def __new_iterator_concepts__ [@http://boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts]] +[def __boost_array_library__ [@http://www.boost.org/doc/html/array.html Boost.Array Library]] +[def __boost_ref__ [@http://www.boost.org/doc/html/ref.html Boost.Ref]] +[def __boost_ref_call__ [@http://www.boost.org/doc/html/ref.html `ref`]] +[def __std_pair_doc__ [@http://www.sgi.com/tech/stl/pair.html `std::pair`]] + +[def __mpl_integral_constant__ MPL Integral Constant] +[def __mpl_boolean_constant__ MPL Boolean Constant] +[def __mpl_metafunction_class__ MPL Metafunction Class] +[def __mpl_lambda_expression__ MPL Lambda Expression] +[def __lvalue__ LValue] +[def __unspecified__ /unspecified/] + +[def __support__ [link fusion.support Support]] +[def __is_sequence__ [link fusion.support.is_sequence `is_sequence`]] +[def __is_view__ [link fusion.support.is_view `is_view`]] +[def __tag_of__ [link fusion.support.tag_of `tag_of`]] +[def __category_of__ [link fusion.support.category_of `category_of`]] +[def __fusion_pair__ [link fusion.support.pair `fusion::pair`]] +[def __pair__ [link fusion.support.pair `pair`]] +[def __fusion_make_pair__ [link fusion.support.pair `make_pair`]] + +[def __iterator__ [link fusion.iterators Iterator]] +[def __iterator_concepts__ [link fusion.iterators.concepts Iterator Concepts]] +[def __forward_iterator__ [link fusion.iterators.concepts.forward_iterator Forward Iterator]] +[def __bidirectional_iterator__ [link fusion.iterators.concepts.bidirectional_iterator Bidirectional Iterator]] +[def __random_access_iterator__ [link fusion.iterators.concepts.random_access_iterator Random Access Iterator]] + +[def __next__ [link fusion.iterators.functions.next `next`]] +[def __prior__ [link fusion.iterators.functions.prior `prior`]] +[def __advance__ [link fusion.iterators.functions.advance `advance`]] +[def __advance_c__ [link fusion.iterators.functions.advance_c `advance_c`]] +[def __distance__ [link fusion.iterators.functions.distance `distance`]] +[def __deref__ [link fusion.iterators.functions.deref `deref`]] + +[def __result_of_next__ [link fusion.iterators.metafunctions.next `result_of::next`]] +[def __result_of_prior__ [link fusion.iterators.metafunctions.prior `result_of::prior`]] +[def __result_of_equal_to__ [link fusion.iterators.metafunctions.equal_to `result_of::equal_to`]] +[def __result_of_advance__ [link fusion.iterators.metafunctions.advance `result_of::advance`]] +[def __result_of_advance_c__ [link fusion.iterators.metafunctions.advance_c `result_of::advance_c`]] +[def __result_of_distance__ [link fusion.iterators.metafunctions.distance `result_of::distance`]] +[def __result_of_deref__ [link fusion.iterators.metafunctions.deref `result_of::deref`]] +[def __result_of_value_of__ [link fusion.iterators.metafunctions.value_of `result_of::value_of`]] +[def __value_of__ [link fusion.iterators.metafunctions.value_of `value_of`]] + +[def __sequence__ [link fusion.sequences Sequence]] +[def __sequence_concepts__ [link fusion.sequences.concepts Sequence Concepts]] +[def __traversal_concept__ [link fusion.sequences.concepts.traversal Sequence Traversal Concept]] +[def __associativity_concept__ [link fusion.sequences.concepts.associativity Sequence Associativity Concept]] +[def __forward_sequence__ [link fusion.sequences.concepts.forward_sequence Forward Sequence]] +[def __bidirectional_sequence__ [link fusion.sequences.concepts.bidirectional_sequence Bidirectional Sequence]] +[def __random_access_sequence__ [link fusion.sequences.concepts.random_access_sequence Random Access Sequence]] +[def __associative_sequence__ [link fusion.sequences.concepts.associative_sequence Associative Sequence]] + +[def __containers__ [link fusion.sequences.containers Containers]] +[def __vector__ [link fusion.sequences.containers.vector `vector`]] +[def __cons__ [link fusion.sequences.containers.cons `cons`]] +[def __list__ [link fusion.sequences.containers.list `list`]] +[def __set__ [link fusion.sequences.containers.set `set`]] +[def __map__ [link fusion.sequences.containers.map `map`]] + +[def __view__ [link fusion.sequences.views View]] +[def __views__ [link fusion.sequences.views Views]] +[def __single_view__ [link fusion.sequences.views.single_view `single_view`]] +[def __filter_view__ [link fusion.sequences.views.filter_view `filter_view`]] +[def __iterator_range__ [link fusion.sequences.views.iterator_range `iterator_range`]] +[def __joint_view__ [link fusion.sequences.views.joint_view `joint_view`]] +[def __transform_view__ [link fusion.sequences.views.transform_view `transform_view`]] +[def __reverse_view__ [link fusion.sequences.views.reverse_view `reverse_view`]] + +[def __std_pair__ [link fusion.sequences.adapted.std__pair `std::pair`]] +[def __boost_array__ [link fusion.sequences.adapted.boost__array `boost::array`]] +[def __mpl_sequence__ [link fusion.sequences.adapted.mpl_sequence mpl sequence]] + +[def __intrinsic__ [link fusion.sequences.intrinsics Intrinsic]] +[def __intrinsics__ [link fusion.sequences.intrinsics Intrinsics]] +[def __begin__ [link fusion.sequences.intrinsics.functions.begin `begin`]] +[def __result_of_begin__ [link fusion.sequences.intrinsics.metafunctions.begin `result_of::begin`]] +[def __end__ [link fusion.sequences.intrinsics.functions.end `end`]] +[def __result_of_end__ [link fusion.sequences.intrinsics.metafunctions.end `result_of::end`]] +[def __size__ [link fusion.sequences.intrinsics.functions.size `size`]] +[def __result_of_size__ [link fusion.sequences.intrinsics.metafunctions.size `result_of::size`]] +[def __empty__ [link fusion.sequences.intrinsics.functions.empty `empty`]] +[def __result_of_empty__ [link fusion.sequences.intrinsics.metafunctions.empty `result_of::empty`]] +[def __front__ [link fusion.sequences.intrinsics.functions.front `front`]] +[def __result_of_front__ [link fusion.sequences.intrinsics.metafunctions.front `result_of::front`]] +[def __back__ [link fusion.sequences.intrinsics.functions.back `back`]] +[def __result_of_back__ [link fusion.sequences.intrinsics.metafunctions.back `result_of::back`]] +[def __at__ [link fusion.sequences.intrinsics.functions.at `at`]] +[def __result_of_at__ [link fusion.sequences.intrinsics.metafunctions.at `result_of::at`]] +[def __at_c__ [link fusion.sequences.intrinsics.functions.at_c `at_c`]] +[def __result_of_at_c__ [link fusion.sequences.intrinsics.metafunctions.at_c `result_of::at_c`]] +[def __at_key__ [link fusion.sequences.intrinsics.functions.at_key `at_key`]] +[def __result_of_at_key__ [link fusion.sequences.intrinsics.metafunctions.at_key `result_of::at_key`]] +[def __has_key__ [link fusion.sequences.intrinsics.functions.has_key `has_key`]] +[def __result_of_has_key__ [link fusion.sequences.intrinsics.metafunctions.has_key `result_of::has_key`]] +[def __value_at_key__ [link fusion.sequences.intrinsics.metafunctions.value_at_key `value_at_key`]] +[def __result_of_value_at__ [link fusion.sequences.intrinsics.metafunctions.value_at `result_of::value_at`]] +[def __result_of_value_at_c__ [link fusion.sequences.intrinsics.metafunctions.value_at_c `result_of::value_at_c`]] +[def __result_of_value_at_key__ [link fusion.sequences.intrinsics.metafunctions.value_at_key `result_of::value_at_key`]] + +[def __conversion__ [link fusion.sequences.conversion.functions Conversion]] +[def __result_of_conversion__ [link fusion.sequences.conversion.metafunctions Conversion Metafunctions]] +[def __as_vector__ [link fusion.sequences.conversion.functions.as_vector `as_vector`]] +[def __result_of_as_vector__ [link fusion.sequences.conversion.metafunctions.as_vector `result_of::as_vector`]] +[def __as_list__ [link fusion.sequences.conversion.functions.as_list `as_list`]] +[def __result_of_as_list__ [link fusion.sequences.conversion.metafunctions.as_list `result_of::as_list`]] +[def __as_set__ [link fusion.sequences.conversion.functions.as_set `as_set`]] +[def __result_of_as_set__ [link fusion.sequences.conversion.metafunctions.as_set `result_of::as_set`]] +[def __as_map__ [link fusion.sequences.conversion.functions.as_map `as_map`]] +[def __result_of_as_map__ [link fusion.sequences.conversion.metafunctions.as_map `result_of::as_map`]] + +[def __generation__ [link fusion.sequences.generation.functions Generation]] +[def __result_of_generation__ [link fusion.sequences.generation.metafunctions Generation Metafunctions]] +[def __make_vector__ [link fusion.sequences.generation.functions.make_vector `make_vector`]] +[def __result_of_make_vector__ [link fusion.sequences.generation.metafunctions.make_vector `result_of::make_vector`]] +[def __vector_tie__ [link fusion.sequences.generation.functions.vector_tie `vector_tie`]] +[def __result_of_vector_tie__ [link fusion.sequences.generation.metafunctions.vector_tie `result_of::vector_tie`]] +[def __make_vector__ [link fusion.sequences.generation.functions.make_vector `make_vector`]] +[def __result_of_make_vector__ [link fusion.sequences.generation.metafunctions.make_vector `result_of::make_vector`]] +[def __make_cons__ [link fusion.sequences.generation.functions.make_cons `make_cons`]] +[def __result_of_make_cons__ [link fusion.sequences.generation.metafunctions.make_cons `result_of::make_cons`]] +[def __make_list__ [link fusion.sequences.generation.functions.make_list `make_list`]] +[def __result_of_make_list__ [link fusion.sequences.generation.metafunctions.make_list `result_of::make_list`]] +[def __make_set__ [link fusion.sequences.generation.functions.make_set `make_set`]] +[def __result_of_make_set__ [link fusion.sequences.generation.metafunctions.make_set `result_of::make_set`]] +[def __make_map__ [link fusion.sequences.generation.functions.make_map `make_map`]] +[def __result_of_make_map__ [link fusion.sequences.generation.metafunctions.make_map `result_of::make_map`]] +[def __list_tie__ [link fusion.sequences.generation.functions.list_tie `list_tie`]] +[def __result_of_list_tie__ [link fusion.sequences.generation.metafunctions.list_tie `result_of::list_tie`]] + +[def __out__ [link fusion.sequences.operators.i_o.out out]] +[def __in__ [link fusion.sequences.operators.i_o.in in]] +[def __eq__ [link fusion.sequences.operators.comparison.equal equal]] +[def __neq__ [link fusion.sequences.operators.comparison.not_equal not equal]] +[def __lt__ [link fusion.sequences.operators.comparison.less_than less than]] +[def __lte__ [link fusion.sequences.operators.comparison.less_than_equal less than equal]] +[def __gt__ [link fusion.sequences.operators.comparison.greater_than greater than]] +[def __gte__ [link fusion.sequences.operators.comparison.greater_than_equal greater than equal]] + +[def __algorithm__ [link fusion.algorithms Algorithm]] +[def __algorithms__ [link fusion.algorithms Algorithms]] +[def __poly_func_obj__ [link fusion.algorithms.concepts.polymorphic_function_object Polymorphic Function Object]] +[def __fold__ [link fusion.algorithms.iteration.functions.fold `fold`]] +[def __result_of_fold__ [link fusion.algorithms.iteration.metafunctions.fold `result_of::fold`]] +[def __accumulate__ [link fusion.algorithms.iteration.functions.accumulate `accumulate`]] +[def __result_of_accumulate__ [link fusion.algorithms.iteration.metafunctions.accumulate `result_of::accumulate`]] +[def __for_each__ [link fusion.algorithms.iteration.functions.for_each `for_each`]] +[def __result_of_for_each__ [link fusion.algorithms.iteration.metafunctions.for_each `result_of::for_each`]] +[def __any__ [link fusion.algorithms.query.functions.any `any`]] +[def __result_of_any__ [link fusion.algorithms.query.metafunctions.any `result_of::any`]] +[def __all__ [link fusion.algorithms.query.functions.all `all`]] +[def __result_of_all__ [link fusion.algorithms.query.metafunctions.all `result_of::all`]] +[def __none__ [link fusion.algorithms.query.functions.none `none`]] +[def __result_of_none__ [link fusion.algorithms.query.metafunctions.none `result_of::none`]] +[def __find__ [link fusion.algorithms.query.functions.find `find`]] +[def __result_of_find__ [link fusion.algorithms.query.metafunctions.find `result_of::find`]] +[def __find_if__ [link fusion.algorithms.query.functions.find_if `find_if`]] +[def __result_of_find_if__ [link fusion.algorithms.query.metafunctions.find_if `result_of::find_if`]] +[def __count__ [link fusion.algorithms.query.functions.count `count`]] +[def __result_of_count__ [link fusion.algorithms.query.metafunctions.count `result_of::count`]] +[def __count_if__ [link fusion.algorithms.query.functions.count_if `count_if`]] +[def __result_of_count_if__ [link fusion.algorithms.query.metafunctions.count_if `result_of::count_if`]] +[def __filter__ [link fusion.algorithms.transformation.functions.filter `filter`]] +[def __result_of_filter__ [link fusion.algorithms.transformation.metafunctions.filter `result_of::filter`]] +[def __filter_if__ [link fusion.algorithms.transformation.functions.filter_if `filter_if`]] +[def __result_of_filter_if__ [link fusion.algorithms.transformation.metafunctions.filter_if `result_of::filter_if`]] +[def __transform__ [link fusion.algorithms.transformation.functions.transform `transform`]] +[def __result_of_transform__ [link fusion.algorithms.transformation.metafunctions.transform `result_of::transform`]] +[def __replace__ [link fusion.algorithms.transformation.functions.replace `replace`]] +[def __result_of_replace__ [link fusion.algorithms.transformation.metafunctions.replace `result_of::replace`]] +[def __replace_if__ [link fusion.algorithms.transformation.functions.replace_if `replace_if`]] +[def __result_of_replace_if__ [link fusion.algorithms.transformation.metafunctions.replace_if `result_of::replace_if`]] +[def __remove__ [link fusion.algorithms.transformation.functions.remove `remove`]] +[def __result_of_remove__ [link fusion.algorithms.transformation.metafunctions.remove `result_of::remove`]] +[def __remove_if__ [link fusion.algorithms.transformation.functions.remove_if `remove_if`]] +[def __result_of_remove_if__ [link fusion.algorithms.transformation.metafunctions.remove_if `result_of::remove_if`]] +[def __reverse__ [link fusion.algorithms.transformation.functions.reverse `reverse`]] +[def __result_of_reverse__ [link fusion.algorithms.transformation.metafunctions.reverse `result_of::reverse`]] +[def __clear__ [link fusion.algorithms.transformation.functions.clear `clear`]] +[def __result_of_clear__ [link fusion.algorithms.transformation.metafunctions.clear `result_of::clear`]] +[def __erase__ [link fusion.algorithms.transformation.functions.erase `erase`]] +[def __result_of_erase__ [link fusion.algorithms.transformation.metafunctions.erase `result_of::erase`]] +[def __erase_key__ [link fusion.algorithms.transformation.functions.erase_key `erase_key`]] +[def __result_of_erase_key__ [link fusion.algorithms.transformation.metafunctions.erase_key `result_of::erase_key`]] +[def __insert__ [link fusion.algorithms.transformation.functions.insert `insert`]] +[def __result_of_insert__ [link fusion.algorithms.transformation.metafunctions.insert `result_of::insert`]] +[def __insert_range__ [link fusion.algorithms.transformation.functions.insert_range `insert_range`]] +[def __result_of_insert_range__ [link fusion.algorithms.transformation.metafunctions.insert_range `result_of::insert_range`]] +[def __join__ [link fusion.algorithms.transformation.functions.join `join`]] +[def __result_of_join__ [link fusion.algorithms.transformation.metafunctions.join `result_of::join`]] +[def __zip__ [link fusion.algorithms.transformation.functions.zip `zip`]] +[def __result_of_zip__ [link fusion.algorithms.transformation.metafunctions.zip `result_of::zip`]] +[def __pop_back__ [link fusion.algorithms.transformation.functions.pop_back `pop_back`]] +[def __result_of_pop_back__ [link fusion.algorithms.transformation.metafunctions.pop_back `result_of::pop_back`]] +[def __pop_front__ [link fusion.algorithms.transformation.functions.pop_front `pop_front`]] +[def __result_of_pop_front__ [link fusion.algorithms.transformation.metafunctions.pop_front `result_of::pop_front`]] +[def __push_back__ [link fusion.algorithms.transformation.functions.push_back `push_back`]] +[def __result_of_push_back__ [link fusion.algorithms.transformation.metafunctions.push_back `result_of::push_back`]] +[def __push_front__ [link fusion.algorithms.transformation.functions.push_front `push_front`]] +[def __result_of_push_front__ [link fusion.algorithms.transformation.metafunctions.push_front `result_of::push_front`]] + +[def __tr1_tuple_pair__ [link fusion.tuples.pairs `TR1 and std::pair`]] +[def __tuple_get__ [link fusion.tuples.class_template_tuple.element_access `get`]] + +[def __recursive_inline__ [link fusion.notes.recursive_inlined_functions Recursive Inlined Functions]] +[def __overloaded_functions__ [link fusion.notes.overloaded_functions Overloaded Functions]] +[def __tag_dispatching__ [link fusion.notes.tag_dispatching /tag dispatching/]] +[def __element_conversion__ [link fusion.notes.element_conversion /element conversion/]] +[def __see_element_conversion__ [link fusion.notes.element_conversion /see element conversion/]] +[def __note_boost_ref__ [link fusion.notes.boost__ref `boost::ref`]] + +[def __quick_start__ [link fusion.quick_start Quick Start]] +[def __organization__ [link fusion.organization Orgainization]] +[def __extension__ [link fusion.extension Extension]] + +[include preface.qbk] +[include introduction.qbk] +[include quick_start.qbk] +[include organization.qbk] +[include support.qbk] +[include iterators.qbk] +[include sequences.qbk] +[include algorithms.qbk] +[include tuples.qbk] +[include extension.qbk] +[include notes.qbk] +[include changelog.qbk] +[include acknowledgements.qbk] +[include references.qbk] + diff --git a/doc/html/boostbook.css b/doc/html/boostbook.css new file mode 100755 index 00000000..d84d5384 --- /dev/null +++ b/doc/html/boostbook.css @@ -0,0 +1,511 @@ +/*============================================================================= + Copyright (c) 2004 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +/*============================================================================= + Body defaults +=============================================================================*/ + + body + { + margin: 1em; + font-family: sans-serif; + } + +/*============================================================================= + Paragraphs +=============================================================================*/ + + p + { + text-align: left; + font-size: 10pt; + line-height: 1.15; + } + +/*============================================================================= + Program listings +=============================================================================*/ + + /* Code on paragraphs */ + p tt.computeroutput + { + font-size: 9pt; + } + + pre.synopsis + { + font-size: 90%; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + .programlisting, + .screen + { + font-size: 9pt; + display: block; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + /* Program listings in tables don't get borders */ + td .programlisting, + td .screen + { + margin: 0pc 0pc 0pc 0pc; + padding: 0pc 0pc 0pc 0pc; + } + +/*============================================================================= + Headings +=============================================================================*/ + + h1, h2, h3, h4, h5, h6 + { + text-align: left; + margin: 1em 0em 0.5em 0em; + font-weight: bold; + } + + h1 { font: 140% } + h2 { font: bold 140% } + h3 { font: bold 130% } + h4 { font: bold 120% } + h5 { font: italic 110% } + h6 { font: italic 100% } + + /* Top page titles */ + title, + h1.title, + h2.title + h3.title, + h4.title, + h5.title, + h6.title, + .refentrytitle + { + font-weight: bold; + margin-bottom: 1pc; + } + + h1.title { font-size: 140% } + h2.title { font-size: 140% } + h3.title { font-size: 130% } + h4.title { font-size: 120% } + h5.title { font-size: 110% } + h6.title { font-size: 100% } + + .section h1 + { + margin: 0em 0em 0.5em 0em; + font-size: 140%; + } + + .section h2 { font-size: 140% } + .section h3 { font-size: 130% } + .section h4 { font-size: 120% } + .section h5 { font-size: 110% } + .section h6 { font-size: 100% } + + /* Code on titles */ + h1 tt.computeroutput { font-size: 140% } + h2 tt.computeroutput { font-size: 140% } + h3 tt.computeroutput { font-size: 130% } + h4 tt.computeroutput { font-size: 120% } + h5 tt.computeroutput { font-size: 110% } + h6 tt.computeroutput { font-size: 100% } + +/*============================================================================= + Author +=============================================================================*/ + + h3.author + { + font-size: 100% + } + +/*============================================================================= + Lists +=============================================================================*/ + + li + { + font-size: 10pt; + line-height: 1.3; + } + + /* Unordered lists */ + ul + { + text-align: left; + } + + /* Ordered lists */ + ol + { + text-align: left; + } + +/*============================================================================= + Links +=============================================================================*/ + + a + { + text-decoration: none; /* no underline */ + } + + a:hover + { + text-decoration: underline; + } + +/*============================================================================= + Spirit style navigation +=============================================================================*/ + + .spirit-nav + { + text-align: right; + } + + .spirit-nav a + { + color: white; + padding-left: 0.5em; + } + + .spirit-nav img + { + border-width: 0px; + } + +/*============================================================================= + Table of contents +=============================================================================*/ + + .toc + { + margin: 1pc 4% 0pc 4%; + padding: 0.1pc 1pc 0.1pc 1pc; + font-size: 80%; + line-height: 1.15; + } + + .boost-toc + { + float: right; + padding: 0.5pc; + } + +/*============================================================================= + Tables +=============================================================================*/ + + .table-title, + div.table p.title + { + margin-left: 4%; + padding-right: 0.5em; + padding-left: 0.5em; + } + + .informaltable table, + .table table + { + width: 92%; + margin-left: 4%; + margin-right: 4%; + } + + div.informaltable table, + div.table table + { + padding: 4px; + } + + /* Table Cells */ + div.informaltable table tr td, + div.table table tr td + { + padding: 0.5em; + text-align: left; + font-size: 9pt; + } + + div.informaltable table tr th, + div.table table tr th + { + padding: 0.5em 0.5em 0.5em 0.5em; + border: 1pt solid white; + font-size: 80%; + } + +/*============================================================================= + Blurbs +=============================================================================*/ + + div.note, + div.tip, + div.important, + div.caution, + div.warning, + p.blurb + { + font-size: 9pt; /* A little bit smaller than the main text */ + line-height: 1.2; + display: block; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + p.blurb img + { + padding: 1pt; + } + +/*============================================================================= + Variable Lists +=============================================================================*/ + + /* Make the terms in definition lists bold */ + div.variablelist dl dt, + span.term + { + font-weight: bold; + font-size: 10pt; + } + + div.variablelist table tbody tr td + { + text-align: left; + vertical-align: top; + padding: 0em 2em 0em 0em; + font-size: 10pt; + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + + div.variablelist dl dt + { + margin-bottom: 0.2em; + } + + div.variablelist dl dd + { + margin: 0em 0em 0.5em 2em; + font-size: 10pt; + } + + div.variablelist table tbody tr td p, + div.variablelist dl dd p + { + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + +/*============================================================================= + Misc +=============================================================================*/ + + /* Title of books and articles in bibliographies */ + span.title + { + font-style: italic; + } + + span.underline + { + text-decoration: underline; + } + + span.strikethrough + { + text-decoration: line-through; + } + + /* Copyright, Legal Notice */ + div div.legalnotice p + { + text-align: left + } + +/*============================================================================= + Colors +=============================================================================*/ + + @media screen + { + /* Links */ + a + { + color: #005a9c; + } + + a:visited + { + color: #9c5a9c; + } + + h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, + h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover, + h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited + { + text-decoration: none; /* no underline */ + color: #000000; + } + + /* Syntax Highlighting */ + .keyword { color: #0000AA; } + .identifier { color: #000000; } + .special { color: #707070; } + .preprocessor { color: #402080; } + .char { color: teal; } + .comment { color: #800000; } + .string { color: teal; } + .number { color: teal; } + .white_bkd { background-color: #FFFFFF; } + .dk_grey_bkd { background-color: #999999; } + + /* Copyright, Legal Notice */ + .copyright + { + color: #666666; + font-size: small; + } + + div div.legalnotice p + { + color: #666666; + } + + /* Program listing */ + pre.synopsis + { + border: 1px solid #DCDCDC; + } + + .programlisting, + .screen + { + border: 1px solid #DCDCDC; + } + + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; + } + + /* Blurbs */ + div.note, + div.tip, + div.important, + div.caution, + div.warning, + p.blurb + { + border: 1px solid #DCDCDC; + } + + /* Table of contents */ + .toc + { + border: 1px solid #DCDCDC; + } + + /* Tables */ + div.informaltable table tr td, + div.table table tr td + { + border: 1px solid #DCDCDC; + } + + div.informaltable table tr th, + div.table table tr th + { + background-color: #F0F0F0; + border: 1px solid #DCDCDC; + } + + /* Misc */ + span.highlight + { + color: #00A000; + } + } + + @media print + { + /* Links */ + a + { + color: black; + } + + a:visited + { + color: black; + } + + .spirit-nav + { + display: none; + } + + /* Program listing */ + pre.synopsis + { + border: 1px solid gray; + } + + .programlisting, + .screen + { + border: 1px solid gray; + } + + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; + } + + /* Table of contents */ + .toc + { + border: 1px solid gray; + } + + .informaltable table, + .table table + { + border: 1px solid gray; + border-collapse: collapse; + } + + /* Tables */ + div.informaltable table tr td, + div.table table tr td + { + border: 1px solid gray; + } + + div.informaltable table tr th, + div.table table tr th + { + border: 1px solid gray; + } + + /* Misc */ + span.highlight + { + font-weight: bold; + } + } diff --git a/doc/html/fusion/acknowledgements.html b/doc/html/fusion/acknowledgements.html new file mode 100644 index 00000000..11f4df57 --- /dev/null +++ b/doc/html/fusion/acknowledgements.html @@ -0,0 +1,44 @@ + + + +Acknowledgements + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Special thanks to David Abrahams, Hartmut Kaiser, Aleksey Gurtovoy, Peder Holt, + Daniel Wallin, Jaakko Jarvi, Jeremiah Willcock, Dan Marsden, Eric Niebler, + Joao Abecasis. These people are instrumental in the design and development + of Fusion. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms.html b/doc/html/fusion/algorithms.html new file mode 100644 index 00000000..8f461e33 --- /dev/null +++ b/doc/html/fusion/algorithms.html @@ -0,0 +1,98 @@ + + + +Algorithms + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ + Lazy Evaluation +

+

+ Unlike MPL, Fusion + algorithms are lazy and non sequence-type preserving. What does that mean? + It means that when you operate on a sequence through a Fusion algorithm that + returns a sequence, the sequence returned may not be of the same class as the + original. This is by design. Runtime efficiency is given a high priority. Like + MPL, and unlike + STL, + fusion algorithms are functional in nature such that algorithms are non mutating + (no side effects). However, due to the high cost of returning full sequences + such as vectors and lists, Views are returned from Fusion + algorithms instead. For example, the transform algorithm does not actually + return a transformed version of the original sequence. transform returns a transform_view. This view holds a + reference to the original sequence plus the transform function. Iteration over + the transform_view + will apply the transform function over the sequence elements on demand. This + lazy evaluation scheme allows us to chain as many algorithms + as we want without incurring a high runtime penalty. +

+

+ + Sequence Extension +

+

+ The lazy evaluation scheme where Algorithms + return Views also allows operations + such as push_back to be totally generic. In + Fusion, push_back is actually a generic algorithm + that works on all sequences. Given an input sequence s + and a value x, Fusion's push_back algorithm simply returns + a joint_view: + a view that holds a reference to the original sequence s + and the value x. Functions + that were once sequence specific and need to be implemented N times over N + different sequences are now implemented only once. That is to say that Fusion + sequences are cheaply extensible. However, an important caveat is that the + result of a sequence extending operation like push_back does not retain the properties + of the original sequence such as associativity of _set_s. + To regain the original sequence, Conversion + functions are provided. You may use one of the Conversion + functions to convert back to the original sequence type. +

+

+ + Header +

+
+#include <boost/fusion/algorithm.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/concepts.html b/doc/html/fusion/algorithms/concepts.html new file mode 100644 index 00000000..991a3c20 --- /dev/null +++ b/doc/html/fusion/algorithms/concepts.html @@ -0,0 +1,41 @@ + + + +Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/concepts/polymorphic_function_object.html b/doc/html/fusion/algorithms/concepts/polymorphic_function_object.html new file mode 100644 index 00000000..2c3dee28 --- /dev/null +++ b/doc/html/fusion/algorithms/concepts/polymorphic_function_object.html @@ -0,0 +1,109 @@ + + + +Polymorphic + Function Object + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A type of function object with a nested metafunction result. + result returns the result + type of calling the function object, given the argument types. +

+
+

Notation

+
+
F
+
+ A Polymorphic Function Object type +
+
f
+
+ A Polymorphic Function Object +
+
T1 + ...TN
+
+ Arbitrary types +
+
t1 + ...tN
+
+ Objects with types T1 ...TN +
+
+
+
+ + Refinement + of +
+

+ MPL Metafunction Class +

+
+ + Expression + requirements +
+
+

+ +

+ +++++ + + + + + + + + + + +
ExpressionReturn TypeRuntime + Complexity
f(t1, ...tN)F::result<T1, ...TN>::typeUnspecified
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration.html b/doc/html/fusion/algorithms/iteration.html new file mode 100644 index 00000000..e971e124 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration.html @@ -0,0 +1,54 @@ + + + +Iteration + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The iteration algorithms provide the fundamental algorithms for traversing + a sequence repeatedly applying an operation to its elements. +

+

+ + Header +

+
+#include <boost/fusion/algorithm/iteration.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/functions.html b/doc/html/fusion/algorithms/iteration/functions.html new file mode 100644 index 00000000..5c3db0bd --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/functions.html @@ -0,0 +1,43 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/functions/accumulate.html b/doc/html/fusion/algorithms/iteration/functions/accumulate.html new file mode 100644 index 00000000..f04005b7 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/functions/accumulate.html @@ -0,0 +1,161 @@ + + + +accumulate + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Repeatedly applies binary Polymorphic + Function Object f + to each element of a sequence and the previous state. accumulate is equivalent to + fold. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename State,
+    typename F
+    >
+typename result_of::accumulate<Sequence, State, F>::type accumulate(
+    Sequence& seq, State const& initial_state, F const& f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(eN ....f(e2,f(e1,initial_state))) must be a valid expression for + each element e1 + to eN in seq +Operation's + argument
initial_stateAny + typeInitial state
fA + model of binary Polymorphic + Function Object +Operation's argument
+
+
+ + Expression + Semantics +
+
+accumulate(seq, initial_state, f);
+
+

+ Return type: Any type +

+

+ Semantics: Equivalent to f(eN ....f(e2,f(e1,initial_state))) + where e1 ...eN are the elements of seq. +

+
+ + Complexity +
+

+ Linear, exactly result_of::size<Sequence>::value applications of f. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/accumulate.hpp>
+
+
+ + Example +
+
+struct make_string
+{
+    template<typename T, typename State>
+    struct apply
+    {
+        typedef std::string type;
+    };
+
+    template<typename T>
+    std::string operator()(const T& t, const std::string& str) const
+    {
+        return str + boost::lexical_cast<std::string>(t);
+    }
+};
+...
+const vector<int,int> vec(1,2);
+assert(accumulate(vec,std::string(""), make_string()) == "12");
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/functions/fold.html b/doc/html/fusion/algorithms/iteration/functions/fold.html new file mode 100644 index 00000000..43ac4e62 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/functions/fold.html @@ -0,0 +1,160 @@ + + + +fold + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Repeatedly applies binary Polymorphic + Function Object f + to each element of a sequence and the previous state. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename State,
+    typename F
+    >
+typename result_of::fold<Sequence, State, F>::type fold(
+    Sequence& seq, State const& initial_state, F const& f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence,f(e) must be a valid expression for + each element e + in seq +Operation's + argument
initial_stateAny + typeInitial state
fA + model of binary Polymorphic + Function Object +Operation's argument
+
+
+ + Expression + Semantics +
+
+fold(seq, initial_state, f);
+
+

+ Return type: Any type +

+

+ Semantics: Equivalent to f(eN ....f(e2,f(e1,initial_state))) + where e1 ...eN are the elements of seq. +

+
+ + Complexity +
+

+ Linear, exactly result_of::size<Sequence>::value applications of f. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/fold.hpp>
+
+
+ + Example +
+
+struct make_string
+{
+    template<typename T, typename State>
+    struct apply
+    {
+        typedef std::string type;
+    };
+
+    template<typename T>
+    std::string operator()(const T& t, const std::string& str) const
+    {
+        return str + boost::lexical_cast<std::string>(t);
+    }
+};
+...
+const vector<int,int> vec(1,2);
+assert(fold(vec,std::string(""), make_string()) == "12");
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/functions/for_each.html b/doc/html/fusion/algorithms/iteration/functions/for_each.html new file mode 100644 index 00000000..c7ad7ceb --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/functions/for_each.html @@ -0,0 +1,142 @@ + + + +for_each + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Applies a unary function object to each element of a sequence. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::for_each<Sequence, F>::type for_each(
+    Sequence& seq, F const& f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(e) must be a valid expression for + each element e + in seq +Operation's + argument
fA + unary function objectOperation's argument
+
+
+ + Expression + Semantics +
+
+for_each(seq, f);
+
+

+ Return type: void +

+

+ Semantics: Calls f(e) for each element e + in seq. +

+
+ + Complexity +
+

+ Linear, exactly result_of::size<Sequence>::value applications of f. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+
+
+ + Example +
+
+struct increment
+{
+    template<typename T>
+    void operator()(T& t) const
+    {
+        ++t;
+    }
+};
+...
+vector<int,int> vec(1,2);
+for_each(vec, increment());
+assert(vec == make_vector(2,3));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/metafunctions.html b/doc/html/fusion/algorithms/iteration/metafunctions.html new file mode 100644 index 00000000..1bd66d25 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/metafunctions.html @@ -0,0 +1,43 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/metafunctions/accumulate.html b/doc/html/fusion/algorithms/iteration/metafunctions/accumulate.html new file mode 100644 index 00000000..ca944b76 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/metafunctions/accumulate.html @@ -0,0 +1,140 @@ + + + +accumulate + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of accumulate. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename State,
+    typename F>
+struct accumulate
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +The sequence to iterate
StateAny + typeThe initial state for the first application + of F +
FA + model of binary Polymorphic + Function Object +The operation to be applied + on forward traversal
+
+
+ + Expression + Semantics +
+
+result_of::accumulate<Sequence, State, F>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the result of applying + accumulate to a sequence + of type Sequence, with + an initial state of type State + and binary Polymorphic + Function Object of type F. +

+
+ + Complexity +
+

+ Linear, exactly result_of::size<Sequence>::value applications of F. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/accumulate.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/metafunctions/fold.html b/doc/html/fusion/algorithms/iteration/metafunctions/fold.html new file mode 100644 index 00000000..b6fcd011 --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/metafunctions/fold.html @@ -0,0 +1,140 @@ + + + +fold + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of fold. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename State,
+    typename F>
+struct fold
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +The sequence to iterate
StateAny + typeThe initial state for the first application + of F +
FA + model of binary Polymorphic + Function Object +The operation to be applied + on forward traversal
+
+
+ + Expression + Semantics +
+
+result_of::fold<Sequence, State, F>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the result of applying + fold to a sequence of + type Sequence, with an + initial state of type State + and binary Polymorphic + Function Object of type F. +

+
+ + Complexity +
+

+ Linear, exactly result_of::size<Sequence>::value applications of F. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/fold.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/iteration/metafunctions/for_each.html b/doc/html/fusion/algorithms/iteration/metafunctions/for_each.html new file mode 100644 index 00000000..3456bd9e --- /dev/null +++ b/doc/html/fusion/algorithms/iteration/metafunctions/for_each.html @@ -0,0 +1,127 @@ + + + +for_each + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ A metafunction returning the result type of applying for_each to a sequence. The + return type of for_each is always void. +

+
+ + Description +
+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+>
+struct for_each
+{
+    typedef void type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
FAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::for_each<Sequence, F>::type
+
+

+ Return type: void. +

+

+ Semantics: Returns the return type of + for_each for a sequence of type + Sequence and a unary + function object F. The + return type is always void. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query.html b/doc/html/fusion/algorithms/query.html new file mode 100644 index 00000000..d9ed8b46 --- /dev/null +++ b/doc/html/fusion/algorithms/query.html @@ -0,0 +1,52 @@ + + + +Query + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The query algorithms provide support for searching and analyzing sequences. +

+

+ + Header +

+
+#include <boost/fusion/algorithm/query.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions.html b/doc/html/fusion/algorithms/query/functions.html new file mode 100644 index 00000000..112f1f24 --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions.html @@ -0,0 +1,47 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/all.html b/doc/html/fusion/algorithms/query/functions/all.html new file mode 100644 index 00000000..b6d8c3a6 --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/all.html @@ -0,0 +1,147 @@ + + + +all + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+all
+
+ + Description +
+

+ For a sequence seq and + unary function object f, + all returns true if + f returns true for every + element of seq. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::all<Sequence,F>::type all(
+    Sequence const& seq, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(e) is a valid expression, convertible + to bool, for every + element e in seq +The sequence + to search
fA + unary function objectThe search predicate
+
+
+ + Expression + Semantics +
+
+all(seq, f);
+
+

+ Return type: bool +

+

+ Semantics: Returns true if and only + if f(e) + evaluates to true for every + element e in seq. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/all.hpp>
+
+
+ + Example +
+
+struct odd
+{
+    template<typename T>
+    bool operator()(T t) const
+    {
+        return t % 2;
+    }
+};
+...
+assert(all(make_vector(1,3), odd()));
+assert(!all(make_vector(1,2), odd()));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/any.html b/doc/html/fusion/algorithms/query/functions/any.html new file mode 100644 index 00000000..bee9a2a6 --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/any.html @@ -0,0 +1,147 @@ + + + +any + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+any
+
+ + Description +
+

+ For a sequence seq and + unary function object f, + any returns true if + f returns true for at + least one element of seq. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::any<Sequence,F>::type any(
+    Sequence const& seq, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(e) must be a valid expression, convertible + to bool, for each + element e in seq +The sequence + to search
fA + unary function objectThe search predicate
+
+
+ + Expression + semantics +
+
+any(seq, f);
+
+

+ Return type: bool +

+

+ Semantics: Returns true if and only + if f(e) + evaluates to true for some + element e in seq. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/any.hpp>
+
+
+ + Example +
+
+struct odd
+{
+    template<typename T>
+    bool operator()(T t) const
+    {
+        return t % 2;
+    }
+};
+...
+assert(any(make_vector(1,2), odd()));
+assert(!any(make_vector(2,4), odd()));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/count.html b/doc/html/fusion/algorithms/query/functions/count.html new file mode 100644 index 00000000..1b9740ff --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/count.html @@ -0,0 +1,134 @@ + + + +count + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the number of elements of a given type within a sequence. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+typename result_of::count<Sequence, T>::type count(
+    Sequence const& seq, T const& t);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, e == t + must be a valid expression, convertible to bool, + for each element e + in seq +The + sequence to search
TAny + typeThe type to count
+
+
+ + Expression + Semantics +
+
+count(seq, t);
+
+

+ Return type: int +

+

+ Semantics: Returns the number of elements + of type T and equal to + t in seq. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/count.hpp>
+
+
+ + Example +
+
+const vector<double,int,int> vec(1.0,2,3);
+assert(count(vec,2) == 1);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/count_if.html b/doc/html/fusion/algorithms/query/functions/count_if.html new file mode 100644 index 00000000..5805c26a --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/count_if.html @@ -0,0 +1,133 @@ + + + +count_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the number of elements within a sequence with a type for which + a given unary function object evaluates to true. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::count_if<Sequence, F>::type count_if(
+    Sequence const& seq, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(e) is a valid expression, convertible + to bool, for each + element e in seq +The sequence + to search
fA + unary function objectThe search predicate
+
+
+ + Expression + Semantics +
+
+count_if(seq, f)
+
+

+ Return type: int +

+

+ Semantics: Returns the number of elements + in seq where f evaluates to true. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/count_if.hpp>
+
+
+ + Example +
+
+const vector<int,int,int> vec(1,2,3);
+assert(count_if(vec,odd()) == 2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/find.html b/doc/html/fusion/algorithms/query/functions/find.html new file mode 100644 index 00000000..6035ea75 --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/find.html @@ -0,0 +1,138 @@ + + + +find + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Finds the first element of a given type within a sequence. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+unspecified find(Sequence const& seq);
+
+template<
+    typename Sequence,
+    typename T
+    >
+unspecified find(Sequence& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +The sequence to search
TAny + typeThe type to search for
+
+
+ + Expression + Semantics +
+
+find<T>(seq)
+
+

+ Return type: A model of the same iterator + category as the iterators of seq. +

+

+ Semantics: Returns an iterator to the + first element of seq + of type T, or end(seq) if there is no such element. Equivalent + to find_if<boost::is_same<_, T> >(seq) +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/find.hpp>
+
+
+ + Example +
+
+const vector<char,int> vec('a','0');
+assert(*find<int>(vec) == '0');
+assert(find<double>(vec) == end(vec));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/find_if.html b/doc/html/fusion/algorithms/query/functions/find_if.html new file mode 100644 index 00000000..2b58c0dd --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/find_if.html @@ -0,0 +1,140 @@ + + + +find_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Finds the first element within a sequence with a type for which a given + MPL Lambda Expression evaluates to boost::mpl::true_. +

+
+ + Description +
+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+unspecified find_if(Sequence const& seq);
+
+template<
+    typename Sequence,
+    typename F
+    >
+unspecified find_if(Sequence& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +The sequence to search
FA + unary MPL Lambda ExpressionThe search predicate
+
+
+ + Expression + Semantics +
+
+find_if<F>(seq)
+
+

+ Return type: An iterator of the same + iterator category as the iterators of seq. +

+

+ Semantics: Returns the first element + of seq for which MPL + Lambda Expression F evaluates + to boost::mpl::true_, or end(seq) + if there is no such element. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/find_if.hpp>
+
+
+ + Example +
+
+const vector<double,int> vec(1.0,2);
+assert(*find_if<is_integral<mpl::_> >(vec) == 2);
+assert(find_if<is_class<mpl::_> >(vec) == end(vec));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/functions/none.html b/doc/html/fusion/algorithms/query/functions/none.html new file mode 100644 index 00000000..c77b7964 --- /dev/null +++ b/doc/html/fusion/algorithms/query/functions/none.html @@ -0,0 +1,147 @@ + + + +none + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ For a sequence seq and + unary function object f, + none returns true if + f returns false for every + element of seq. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::none<Sequence,F>::type none(
+    Sequence const& seq, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence, f(e) is a valid expression, convertible + to bool, for every + element e in seq +The sequence + to search
fA + unary function objectThe search predicate
+
+
+ + Expression + Semantics +
+
+none(seq, f);
+
+

+ Return type: bool +

+

+ Semantics: Returns true if and only + if f(e) + evaluates to false for every + element e in seq. Result equivalent to !any(seq, f). +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/none.hpp>
+
+
+ + Example +
+
+struct odd
+{
+    template<typename T>
+    bool operator()(T t) const
+    {
+        return t % 2;
+    }
+};
+...
+assert(none(make_vector(2,4), odd()));
+assert(!none(make_vector(1,2), odd()));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions.html b/doc/html/fusion/algorithms/query/metafunctions.html new file mode 100644 index 00000000..544b0b11 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions.html @@ -0,0 +1,47 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/all.html b/doc/html/fusion/algorithms/query/metafunctions/all.html new file mode 100644 index 00000000..67f64d97 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/all.html @@ -0,0 +1,131 @@ + + + +all + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+all
+
+ + Description +
+

+ A metafunction returning the result type of all. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+struct all
+{
+    typedef bool type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
FA + model of unary Polymorphic + Function Object +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::all<Sequence, F>::type
+
+

+ Return type: bool. +

+

+ Semantics: Returns the return type of + all + given a sequence of type Sequence + and a unary Polymorphic + Function Object of type F. + The return type is always bool. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/all.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/any.html b/doc/html/fusion/algorithms/query/metafunctions/any.html new file mode 100644 index 00000000..e340607d --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/any.html @@ -0,0 +1,131 @@ + + + +any + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+any
+
+ + Description +
+

+ A metafunction returning the result type of any. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+struct any
+{
+    typedef bool type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
FA + model of unary Polymorphic + Function Object +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::any<Sequence, F>::type
+
+

+ Return type: bool. +

+

+ Semantics: Returns the return type of + any + given a sequence of type Sequence + and a unary Polymorphic + Function Object of type F. + The return type is always bool. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/any.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/count.html b/doc/html/fusion/algorithms/query/metafunctions/count.html new file mode 100644 index 00000000..553c6e75 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/count.html @@ -0,0 +1,126 @@ + + + +count + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A metafunction that returns the result type of count + given the sequence and search types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct count
+{
+    typedef int type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementheading + Description
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::count<T>::type
+
+

+ Return type: int. +

+

+ Semantics: Returns the return type of + count. The return type is always + int. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/count.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/count_if.html b/doc/html/fusion/algorithms/query/metafunctions/count_if.html new file mode 100644 index 00000000..dbc3b485 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/count_if.html @@ -0,0 +1,125 @@ + + + +count_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A metafunction that returns the result type of count_if + given the sequence and predicate types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Pred
+    >
+struct count_if
+{
+    typedef int type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PredA + unary function objectOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::count_if<Sequence, Pred>::type
+
+

+ Return type: int. +

+

+ Semantics: Returns the return type of + count_if. The return type is + always int. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/count_if.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/find.html b/doc/html/fusion/algorithms/query/metafunctions/find.html new file mode 100644 index 00000000..4e580eac --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/find.html @@ -0,0 +1,126 @@ + + + +find + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of find, + given the sequence and search types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct find
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceModel + of Forward + Sequence +Operation's argument
TAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::find<Sequence, T>::type
+
+

+ Return type: A model of the same iterator + category as the iterators of Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Linear, at most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/find.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/find_if.html b/doc/html/fusion/algorithms/query/metafunctions/find_if.html new file mode 100644 index 00000000..43bea426 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/find_if.html @@ -0,0 +1,127 @@ + + + +find_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of find_if + given the sequence and predicate types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Pred
+    >
+struct find_if
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PredA + model of MPL Lambda ExpressionOperation's arguments
+
+
+ + Expression + Semantics +
+
+result_of::find_if<Sequence, Pred>::type
+
+

+ Return type: A model of the same iterator + category as the iterators of Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Linear. At most result_of::size<Sequence>::value comparisons. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/find_if.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/query/metafunctions/none.html b/doc/html/fusion/algorithms/query/metafunctions/none.html new file mode 100644 index 00000000..24bf4693 --- /dev/null +++ b/doc/html/fusion/algorithms/query/metafunctions/none.html @@ -0,0 +1,131 @@ + + + +none + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A metafunction returning the result type of none. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+struct none
+{
+    typedef bool type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
FA + model of unary Polymorphic + Function Object +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::none<Sequence, F>::type
+
+

+ Return type: bool. +

+

+ Semantics: Returns the return type of + none given a sequence of type + Sequence and a unary + Polymorphic + Function Object of type F. + The return type is always bool. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/query/none.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation.html b/doc/html/fusion/algorithms/transformation.html new file mode 100644 index 00000000..2df3fa7c --- /dev/null +++ b/doc/html/fusion/algorithms/transformation.html @@ -0,0 +1,65 @@ + + + +Transformation + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ 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. +

+
+ + + + + +
[Note]Note

+ As the transformation algorithms return views onto their input arguments, + it is important that the lifetime of the input arguments is greater than + the period during which you wish to use the results. +

+

+ + Header +

+
+#include <boost/fusion/algorithm/transformation.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions.html b/doc/html/fusion/algorithms/transformation/functions.html new file mode 100644 index 00000000..49375ca0 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions.html @@ -0,0 +1,59 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/clear.html b/doc/html/fusion/algorithms/transformation/functions/clear.html new file mode 100644 index 00000000..72c3dfb2 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/clear.html @@ -0,0 +1,120 @@ + + + +clear + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ clear returns an empty sequence. +

+
+ + Synposis +
+
+template<
+    typename Sequence
+    >
+typename result_of::clear<Sequence const>::type clear(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+clear(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Expression Semantics: Returns a sequence + with no elements. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/clear.hpp>
+
+
+ + Example +
+
+assert(clear(make_vector(1,2,3)) == make_vector());
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/erase.html b/doc/html/fusion/algorithms/transformation/functions/erase.html new file mode 100644 index 00000000..9bb2bcd6 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/erase.html @@ -0,0 +1,170 @@ + + + +erase + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence, containing all the elements of the original except + those at a specified iterator, or between two iterators. +

+
+ + Synposis +
+
+template<
+    typename Sequence,
+    typename First
+    >
+typename result_of::erase<Sequence const, First>::type erase(
+    Sequence const& seq, First const& it1);
+
+template<
+    typename Sequence,
+    typename First,
+    typename Last
+    >
+typename result_of::erase<Sequence const, First, Last>::type erase(
+    Sequence const& seq, First const& it1, Last const& it2);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParametersRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
it1A + model of Forward + Iterator +Iterator into seq +
it2A + model of Forward + Iterator +Iterator into seq + after it1 +
+
+
+ + Expression + Semantics +
+
+erase(seq, pos);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq + except the element at pos. +

+
+erase(seq, first, last);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, with + all the elements of seq, + in their original order, except those in the range [first,last). +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/erase.hpp>
+
+
+ + Example +
+
+const vector<int, double, char> vec(1, 2.0, 'c');
+assert(erase(vec, next(begin(vec))) == make_vector(1, 'c'));
+assert(erase(vec, next(begin(vec)), end(vec)) == make_vector(1));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/erase_key.html b/doc/html/fusion/algorithms/transformation/functions/erase_key.html new file mode 100644 index 00000000..dd349716 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/erase_key.html @@ -0,0 +1,136 @@ + + + +erase_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ For an Associative + Sequence seq, + returns a Forward + Sequence containing all the elements of the original except those + with a given key. +

+
+ + Synposis +
+
+template<
+    typename Key,
+    typename Sequence
+    >
+typename result_of::erase_key<Sequence const, Key>::type erase_key(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Associative + Sequence +Operation's argument
KeyAny + typeKey to erase
+
+
+ + Expression + Semantics +
+
+erase_key<Key>(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq, + except those with key Key. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/erase_key.hpp>
+
+
+ + Example +
+
+assert(erase_key<int>(make_map<int, long>('a', 'b')) == make_map<long>('b'));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/filter.html b/doc/html/fusion/algorithms/transformation/functions/filter.html new file mode 100644 index 00000000..7c5d11ec --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/filter.html @@ -0,0 +1,133 @@ + + + +filter + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ For a given sequence, filter returns a new sequences containing only + the elements of a specified type. +

+
+ + Synopsis +
+
+template<
+    typename T,
+    typename Sequence
+    >
+typename result_of::filter<Sequence const, T>::type filter(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
TAny + typeThe type to retain
+
+
+ + Expression + Semantics +
+
+filter<T>(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + all the elements of seq + of type T. Equivalent + to filter_if<boost::same_type<_, T> >(seq). +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/filter.hpp>
+
+
+ + Example +
+
+const vector<int,int,long,long> vec(1,2,3,4);
+assert(filter<int>(vec) == make_vector(1,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/filter_if.html b/doc/html/fusion/algorithms/transformation/functions/filter_if.html new file mode 100644 index 00000000..c39996d4 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/filter_if.html @@ -0,0 +1,136 @@ + + + +filter_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ For a given sequence, filter_if returns a new sequences + containing only the elements with types for which a given MPL Lambda + Expression evaluates to boost::mpl::true_. +

+
+ + Synopsis +
+
+template<
+    typename Pred,
+    typename Sequence
+    >
+typename result_of::filter_if<Sequence const, Pred>::type filter_if(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
PredA + unary MPL Lambda ExpressionThe predicate to filter + by
+
+
+ + Expression + Semantics +
+
+filter_if<Pred>(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + all the elements of seq + with types for which Pred + evaluates to boost::mpl::true_. The order of the retained elements + is the same as in the original sequence. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/filter_if.hpp>
+
+
+ + Example +
+
+const vector<int,int,double,double> vec(1,2,3.0,4.0);
+assert(filter_if<is_integral<mpl::_> >(vec) == make_vector(1,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/insert.html b/doc/html/fusion/algorithms/transformation/functions/insert.html new file mode 100644 index 00000000..b86ff1f3 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/insert.html @@ -0,0 +1,144 @@ + + + +insert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence with all the elements of the original, an a new + element inserted the position described by a given iterator. +

+
+ + Synposis +
+
+template<
+    typename Sequence,
+    typename Pos,
+    typename T
+    >
+unspecified insert(Sequence const& seq, Pos const& pos, T const& t);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
posA + model of Forward + Iterator +The position to insert at
tAny + typeThe value to insert
+
+
+ + Expression + Semantics +
+
+insert(seq, p, t);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq, + in their original order, and a new element with the type and value of + t inserted at iterator + pos. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/insert.hpp>
+
+
+ + Example +
+
+const vector<int,int> vec(1,2);
+assert(insert(vec, next(begin(vec)), 3) == make_vector(1,3,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/insert_range.html b/doc/html/fusion/algorithms/transformation/functions/insert_range.html new file mode 100644 index 00000000..9cb34546 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/insert_range.html @@ -0,0 +1,148 @@ + + + +insert_range + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence with another sequence inserted at a specified + iterator. +

+
+ + Synposis +
+
+template<
+    typename Sequence,
+    typename Pos,
+    typename Range
+    >
+typename result_of::insert_range<Sequence const, Pos, Range>::type insert_range(
+    Sequence const& seq, Pos const& pos, Range const& range);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
posA + model of Forward + Iterator +The position to insert at
rangeA + model of Forward + Sequence +Range to insert
+
+
+ + Expression + Semantics +
+
+insert(seq, pos, range);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq, + and the elements of range + inserted at iterator pos. + All elements retaining their ordering from the orignal sequences. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/insert_range.hpp>
+
+
+ + Example +
+
+const vector<int,int> vec(1,2);
+assert(insert_range(vec, next(begin(vec)), make_vector(3,4)) == make_vector(1,3,4,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/join.html b/doc/html/fusion/algorithms/transformation/functions/join.html new file mode 100644 index 00000000..1573c20e --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/join.html @@ -0,0 +1,136 @@ + + + +join + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Takes 2 sequences and returns a sequence containing the elements of the + first followed by the elements of the second. +

+
+ + Synopsis +
+
+template<
+    typename LhSequence,
+    typename RhSequence>
+typename result_of::join<LhSequence, RhSequence>::type join(LhSequence const& lhs, RhSequence const& rhs);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
lhsA + model of Forward + Sequence +Operation's argument
rhsA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+join(lhs, rhs);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + all the elements of lhs + followed by all the elements of rhs. + The order of th elements is preserved. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/join.hpp>
+
+
+ + Example +
+
+vector<int,char> v1(1, 'a');
+vector<int,char> v2(2, 'b');
+assert(join(v1, v2) == make_vector(1,'a',2,'b'));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/pop_back.html b/doc/html/fusion/algorithms/transformation/functions/pop_back.html new file mode 100644 index 00000000..caa44652 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/pop_back.html @@ -0,0 +1,122 @@ + + + +pop_back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence, with the last element of the original removed. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+typename result_of::pop_back<Sequence const>::type pop_back(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+pop_back(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/pop_back.hpp>
+
+
+ + Example +
+
+assert(___pop_back__(make_vector(1,2,3)) == make_vector(1,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/pop_front.html b/doc/html/fusion/algorithms/transformation/functions/pop_front.html new file mode 100644 index 00000000..f9172e1e --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/pop_front.html @@ -0,0 +1,122 @@ + + + +pop_front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence, with the first element of the original removed. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+typename result_of::pop_front<Sequence const>::type pop_front(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+pop_front(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/pop_front.hpp>
+
+
+ + Example +
+
+assert(pop_front(make_vector(1,2,3)) == make_vector(2,3));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/push_back.html b/doc/html/fusion/algorithms/transformation/functions/push_back.html new file mode 100644 index 00000000..070431ee --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/push_back.html @@ -0,0 +1,132 @@ + + + +push_back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence with an element added at the end. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+typename result_of::push_back<Sequence, T>::type push_back(
+    Sequence const& seq, T const& t);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
tAny + typeThe value to add to the end
+
+
+ + Expression + Semantics +
+
+push_back(seq, t);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/push_back.hpp>
+
+
+ + Example +
+
+assert(push_back(make_vector(1,2,3),4) == make_vector(1,2,3,4));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/push_front.html b/doc/html/fusion/algorithms/transformation/functions/push_front.html new file mode 100644 index 00000000..b45d816f --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/push_front.html @@ -0,0 +1,133 @@ + + + +push_front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence with an element added at the beginning. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+typename result_of::push_front<Sequence, T>::type push_front(
+    Sequence const& seq, T const& t);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
tAny + typeThe value to add to the beginning
+
+
+ + Expression + Semantics +
+
+push_back(seq, t);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/push_front.hpp>
+
+
+ + Example +
+
+assert(push_front(make_vector(1,2,3),0) == make_vector(0,1,2,3));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/remove.html b/doc/html/fusion/algorithms/transformation/functions/remove.html new file mode 100644 index 00000000..8b4027fe --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/remove.html @@ -0,0 +1,133 @@ + + + +remove + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence, with all the elements of the original sequence, + except those of a given type. +

+
+ + Synopsis +
+
+template<
+    typename T,
+    typename Sequence
+    >
+typename result_of::remove<Sequence const, T>::type replace(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
TAny + typeType to remove
+
+
+ + Expression + Semantics +
+
+remove<T>(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq, + in their original order, except those of type T. + Equivalent to remove_if<boost::is_same<_,T> >(seq). +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/remove.hpp>
+
+
+ + Example +
+
+const vector<int,double> vec(1,2.0);
+assert(remove<double>(vec) == make_vector(1));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/remove_if.html b/doc/html/fusion/algorithms/transformation/functions/remove_if.html new file mode 100644 index 00000000..e18b9580 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/remove_if.html @@ -0,0 +1,133 @@ + + + +remove_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence, containing all the elements of the original except + those where a given unary function object evaluates to true. +

+
+ + Synopsis +
+
+template<
+    typename Pred,
+    typename Sequence
+    >
+typename result_of::remove_if<Sequence const, Pred>::type remove_if(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
PredA + model of unary MPL Lambda ExpressionRemoval predicate
+
+
+ + Expression + Semantics +
+
+remove_if<Pred>(seq);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence, containing + all the elements of seq, + in their original order, except those elements with types for which + Pred evaluates to boost::mpl::true_. Equivalent to filter<boost::mpl::not_<Pred> >(seq). +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/remove_if.hpp>
+
+
+ + Example +
+
+const vector<int,double> vec(1,2.0);
+assert(remove_if<is_floating_point<mpl::_> >(vec) == make_vector(1));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/replace.html b/doc/html/fusion/algorithms/transformation/functions/replace.html new file mode 100644 index 00000000..30a80ed0 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/replace.html @@ -0,0 +1,144 @@ + + + +replace + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Replaces each value within a sequence of a given type and value with + a new value. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+typename result_of::replace<Sequence const, T>::type replace(
+    Sequence const& seq, T const& old_value, T const& new_value);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + 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
old_valueAny + typeValue to replace
new_valueAny + typeReplacement value
+
+
+ + Expression + Semantics +
+
+replace(seq, old_value, new_value);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/replace.hpp>
+
+
+ + Example +
+
+assert(replace(make_vector(1,2), 2, 3) == make_vector(1,3));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/replace_if.html b/doc/html/fusion/algorithms/transformation/functions/replace_if.html new file mode 100644 index 00000000..9840ea19 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/replace_if.html @@ -0,0 +1,154 @@ + + + +replace_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Replaces each element of a given sequence for which an unary function + object evaluates to true + replaced with a new value. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F,
+    typename T>
+typename result_of::replace_if<Sequence const, F, T>::type replace_if(
+    Sequence const& seq, F f, T const& new_value);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
fA + function object for which f(e) is a valid expression, convertible + to bool, for each + element e in seq +Operation's + argument
new_valueAny + typeReplacement value
+
+
+ + Expression + Semantics +
+
+replace_if(seq, f, new_value);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence with + all the elements of seq, + with new_value assigned + to each element for which f + evaluates to true. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/replace_if.hpp>
+
+
+ + Example +
+
+struct odd
+{
+    template<typename T>
+    bool operator()(T t) const
+    {
+        return t % 2;
+    }
+};
+...
+assert(replace_if(make_vector(1,2), odd(), 3) == make_vector(3,2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/reverse.html b/doc/html/fusion/algorithms/transformation/functions/reverse.html new file mode 100644 index 00000000..0544fbbd --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/reverse.html @@ -0,0 +1,121 @@ + + + +reverse + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a new sequence with the elements of the original in reverse order. +

+
+ + Synposis +
+
+template<
+    typename Sequence
+    >
+typename result_of::reverse<Sequence const>::type reverse(Sequence const& seq);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Bidirectional + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+reverse(seq);
+
+

+ Return type: A model of Bidirectional + Sequence. +

+

+ Semantics: Returns a new sequence containing + all the elements of seq + in reverse order. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/reverse.hpp>
+
+
+ + Example +
+
+assert(reverse(make_vector(1,2,3)) == make_vector(3,2,1));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/transform.html b/doc/html/fusion/algorithms/transformation/functions/transform.html new file mode 100644 index 00000000..d7d71d7b --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/transform.html @@ -0,0 +1,231 @@ + + + +transform + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ For a sequence seq and + Polymorphic + Function Object F, + transform returns a new + sequence with elements created by applying F + to each element of seq. +

+
+ + Unary + version synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+typename result_of::transform<Sequence const, F>::type transform(
+    Sequence const& seq, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqA + model of Forward + Sequence +Operation's argument
fA + model of unary Polymorphic + Function Object where f(e) is a valid expression for each + element e of seq +Transformation + function
+
+
+ + Expression + Semantics +
+
+transform(seq, f);
+
+

+ Return type: A model of Forward + Sequence +

+

+ Semantics: Returns a new sequence, containing + the return values of f(e) for each element e + within seq. +

+
+ + Binary + version synopsis +
+
+template<
+    typename Sequence1,
+    typename Sequence2,
+    typename F
+    >
+typename result_of::transform<Sequence1 const, Sequence2 const, F>::type transform(
+    Sequence1 const& seq1, Sequence2 const& seq2, F f);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seq1A + model of Forward + Sequence +Operation's argument
seq2A + model of Forward + Sequence +Operation's argument
fA + model of binary Polymorphic + Function Object where f(e1, e2) is a valid expression for each + pair of elements e1 + and e2 of seq1 and seq2 + respectivelyTransformation function
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+
+
+ + Example +
+
+struct triple
+{
+    template<typename T>
+    struct apply
+    {
+        typedef T type;
+    };
+
+    template<typename T>
+    T operator()(T t) const
+    {
+        return t * 3;
+    };
+};
+...
+assert(transform(make_vector(1,2,3), triple()) == make_vector(3,6,9));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/functions/zip.html b/doc/html/fusion/algorithms/transformation/functions/zip.html new file mode 100644 index 00000000..1a13b3de --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/functions/zip.html @@ -0,0 +1,132 @@ + + + +zip + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+zip
+
+ + Description +
+

+ Zips sequences together to form a single sequence, whos members are tuples + of the members of the component sequences. +

+
+ + Synopsis +
+
+template<
+    typename Sequence1,
+    typename Sequence2,
+    ...
+    typename SequenceN
+    >
+typename result_of::zip<Sequence1, Sequence2, ... SequenceN>::type 
+zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+seq1 to + seqN +Each + sequence is a model of Forward + Sequence.Operation's argument
+
+
+ + Expression + Semantics +
+
+zip(seq1, seq2, ... seqN);
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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')) +

+
+ + Complexity +
+

+ Constant. Returns a view which is lazily evaluated. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/zip.hpp>
+
+
+ + Example +
+
+vector<int,char> v1(1, 'a');
+vector<int,char> v2(2, 'b');
+assert(zip(v1, v2) == make_vector(make_vector(1, 2),make_vector('a', 'b'));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions.html b/doc/html/fusion/algorithms/transformation/metafunctions.html new file mode 100644 index 00000000..d9dbdf55 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions.html @@ -0,0 +1,59 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/clear.html b/doc/html/fusion/algorithms/transformation/metafunctions/clear.html new file mode 100644 index 00000000..780610ec --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/clear.html @@ -0,0 +1,113 @@ + + + +clear + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of clear, given the input sequence + type. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+struct clear
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::clear<Sequence>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns an empty sequence. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/clear.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/erase.html b/doc/html/fusion/algorithms/transformation/metafunctions/erase.html new file mode 100644 index 00000000..403a7d9e --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/erase.html @@ -0,0 +1,151 @@ + + + +erase + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Returns the result type of erase, given the input sequence + and range delimiting iterator types. +

+
+ + Description +
+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename It1,
+    typename It2 = unspecified>
+struct erase
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
It1A + model of Forward + Iterator +Operation's argument
It2A + model of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::erase<Sequence, It1>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence with + the element at It1 removed. +

+
+result_of::erase<Sequence, It1, It2>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a new sequence with + the elements between It1 + and It2 removed. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/erase.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/erase_key.html b/doc/html/fusion/algorithms/transformation/metafunctions/erase_key.html new file mode 100644 index 00000000..f8e41c56 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/erase_key.html @@ -0,0 +1,127 @@ + + + +erase_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of erase_key, given the sequence + and key types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Key
+    >
+struct erase_key
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Associative + Sequence +Operation's argument
KeyAny + typeKey type
+
+
+ + Expression + Semantics +
+
+result_of::erase_key<Sequence, Key>::type
+
+

+ Return type: A model of Associative + Sequence. +

+

+ Semantics: Returns a sequence with the + elements of Sequence, + except those with key Key. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/erase_key.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/filter.html b/doc/html/fusion/algorithms/transformation/metafunctions/filter.html new file mode 100644 index 00000000..a921959a --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/filter.html @@ -0,0 +1,128 @@ + + + +filter + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of filter given the sequence type + and type to retain. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct filter
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameter +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeType to retain
+
+
+ + Expression + Semantics +
+
+result_of::filter<Sequence, T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/filter.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/filter_if.html b/doc/html/fusion/algorithms/transformation/metafunctions/filter_if.html new file mode 100644 index 00000000..1caefb3c --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/filter_if.html @@ -0,0 +1,128 @@ + + + +filter_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of filter_if given the sequence + and unary MPL Lambda Expression predicate type. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Pred
+    >
+struct filter_if
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameter +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PredA + unary MPL Lambda ExpressionType to retain
+
+
+ + Expression + Semantics +
+
+result_of::filter_if<Sequence, Pred>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + the elements of Sequence + for which Pred evaluates + to boost::mpl::true_. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/filter_if.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/insert.html b/doc/html/fusion/algorithms/transformation/metafunctions/insert.html new file mode 100644 index 00000000..fca46001 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/insert.html @@ -0,0 +1,138 @@ + + + +insert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of insert, given the sequence, + position iterator and insertion types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Position,
+    typename T
+    >
+struct insert
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PositionA + model of Forward + Iterator +Operation's argument
TAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::insert<Sequence, Position, T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with an + element of type T inserted + at position Position + in Sequence. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/insert.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/insert_range.html b/doc/html/fusion/algorithms/transformation/metafunctions/insert_range.html new file mode 100644 index 00000000..0337ea83 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/insert_range.html @@ -0,0 +1,141 @@ + + + +insert_range + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of insert_range, given the input + sequence, position iterator and insertion range types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Position,
+    typename Range
+    >
+struct insert_range
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PositionA + model of Forward + Iterator +Operation's argument
RangeA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::insert_range<Sequence, Position, Range>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with the + elements of Range inserted + at position Position + into Sequence. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/insert_range.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/join.html b/doc/html/fusion/algorithms/transformation/metafunctions/join.html new file mode 100644 index 00000000..b031f52c --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/join.html @@ -0,0 +1,92 @@ + + + +join + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result of joining 2 sequences, given the sequence types. +

+
+ + Synopsis +
+
+template<
+    typename LhSequence,
+    typename RhSequence
+    >
+struct join
+{
+    typedef unspecified type;
+};
+
+
+ + Expression + Semantics +
+
+result_of::join<LhSequence, RhSequence>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ 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. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/join.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/pop_back.html b/doc/html/fusion/algorithms/transformation/metafunctions/pop_back.html new file mode 100644 index 00000000..b869667c --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/pop_back.html @@ -0,0 +1,118 @@ + + + +pop_back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of pop_back, given the input sequence + type. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+struct pop_back
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::pop_back<Sequence>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with all + the elements of Sequence + except the last element. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/tranformation/pop_back.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/pop_front.html b/doc/html/fusion/algorithms/transformation/metafunctions/pop_front.html new file mode 100644 index 00000000..1aeacfea --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/pop_front.html @@ -0,0 +1,118 @@ + + + +pop_front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of pop_front, given the input sequence + type. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+struct pop_front
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::pop_front<Sequence>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with all + the elements of Sequence + except the first element. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/pop_front.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/push_back.html b/doc/html/fusion/algorithms/transformation/metafunctions/push_back.html new file mode 100644 index 00000000..3f78905b --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/push_back.html @@ -0,0 +1,128 @@ + + + +push_back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of push_back, given the types of + the input sequence and element to push. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct push_back
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::push_back<Sequence, T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with the + elements of Sequence + and an element of type T + added to the end. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/push_back.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/push_front.html b/doc/html/fusion/algorithms/transformation/metafunctions/push_front.html new file mode 100644 index 00000000..5f8045df --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/push_front.html @@ -0,0 +1,128 @@ + + + +push_front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of push_front, given the types + of the input sequence and element to push. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct push_front
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeOperation's argument
+
+
+ + Expression + Semantics +
+
+result_of::push_front<Sequence, T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with the + elements of Sequence + and an element of type T + added to the beginning. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/push_front.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/remove.html b/doc/html/fusion/algorithms/transformation/metafunctions/remove.html new file mode 100644 index 00000000..bbd234f2 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/remove.html @@ -0,0 +1,128 @@ + + + +remove + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of remove, given the sequence and + removal types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct remove
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeRemove elements of this type
+
+
+ + Expression + Semantics +
+
+result_of::remove<Sequence, T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + the elements of Sequence + not of type T. Equivalent + to result_of::replace_if<Sequence, boost::is_same<mpl::_, T> >::type. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/remove.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/remove_if.html b/doc/html/fusion/algorithms/transformation/metafunctions/remove_if.html new file mode 100644 index 00000000..f673602c --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/remove_if.html @@ -0,0 +1,130 @@ + + + +remove_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of remove_if, given the input sequence + and unary MPL Lambda Expression predicate types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename Pred
+    >
+struct remove_if
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
PredA + model of unary MPL Lambda ExpressionRemove elements + which evaluate to boost::mpl::true_ +
+
+
+ + Expression + Semantics +
+
+result_of::remove_if<Sequence, Pred>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence containing + the elements of Sequence + for which Pred evaluates + to boost::mpl::false_. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/remove_if.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/replace.html b/doc/html/fusion/algorithms/transformation/metafunctions/replace.html new file mode 100644 index 00000000..ca5637d6 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/replace.html @@ -0,0 +1,126 @@ + + + +replace + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of replace, given the types of + the input sequence and element to replace. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename T
+    >
+struct replace
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
TAny + typeThe type of the search and replacement objects
+
+
+ + Expression + Semantics +
+
+result_of::replace<Sequence,T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns the return type of + replace. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/replace.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/replace_if.html b/doc/html/fusion/algorithms/transformation/metafunctions/replace_if.html new file mode 100644 index 00000000..ae353135 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/replace_if.html @@ -0,0 +1,137 @@ + + + +replace_if + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of replace_if, given the types + of the sequence, Polymorphic + Function Object predicate and replacement object. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F,
+    typename T>
+struct replace_if
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence +Operation's argument
FA + model of unary Polymorphic + Function Object +Replacement predicate
TAny + typeThe type of the replacement object
+
+
+ + Expression + Semantics +
+
+result_of::replace_if<Sequence,F,T>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns the return type of + replace_if. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/replace_if.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/reverse.html b/doc/html/fusion/algorithms/transformation/metafunctions/reverse.html new file mode 100644 index 00000000..600b47b3 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/reverse.html @@ -0,0 +1,117 @@ + + + +reverse + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of reverse, given the input sequence + type. +

+
+ + Synopsis +
+
+template<
+    typename Sequence
+    >
+struct reverse
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Bidirectional + Sequence +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::reverse<Sequence>::type
+
+

+ Return type: A model of Bidirectional + Sequence. +

+

+ Semantics: Returns a sequence with the + elements in the reverse order to Sequence. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/reverse.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/transform.html b/doc/html/fusion/algorithms/transformation/metafunctions/transform.html new file mode 100644 index 00000000..d56a0602 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/transform.html @@ -0,0 +1,130 @@ + + + +transform + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result of type transform, given the sequence + and Polymorphic + Function Object types. +

+
+ + Synopsis +
+
+template<
+    typename Sequence,
+    typename F
+    >
+struct transform
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + model of Forward + Sequence Operation's argument
FA + model of unary Polymorphic + Function Object +Transformation function object
+
+
+ + Expression + Semantics +
+
+result_of::transform<Sequence, F>::type
+
+

+ Return type: A model of Forward + Sequence. +

+

+ Semantics: Returns a sequence with values + F::apply<E>::type for each element type E in Sequence. +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/algorithms/transformation/metafunctions/zip.html b/doc/html/fusion/algorithms/transformation/metafunctions/zip.html new file mode 100644 index 00000000..64611290 --- /dev/null +++ b/doc/html/fusion/algorithms/transformation/metafunctions/zip.html @@ -0,0 +1,95 @@ + + + +zip + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+zip
+
+ + Description +
+

+ Zips sequences together to form a single sequence, whos members are tuples + of the members of the component sequences. +

+
+ + Synopsis +
+
+template<
+    typename Sequence1,
+    typename Sequence2,
+    ...
+    typename SequenceN
+    >
+struct zip
+{
+    typedef unspecified type;
+};
+
+
+ + Expression + Semantics +
+
+result_of::zip<Sequence1, Sequence2, ... SequenceN>::type
+
+

+ Return type: A model of the most restrictive + traversal category of sequences Sequence1 + to SequenceN. +

+

+ 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')) +

+
+ + Complexity +
+

+ Constant. +

+
+ + Header +
+
+#include <boost/fusion/algorithm/transformation/zip.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/change_log.html b/doc/html/fusion/change_log.html new file mode 100644 index 00000000..71050df0 --- /dev/null +++ b/doc/html/fusion/change_log.html @@ -0,0 +1,41 @@ + + + +Change log + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This section summarizes significant changes to the Fusion library. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/extension.html b/doc/html/fusion/extension.html new file mode 100644 index 00000000..be3d339c --- /dev/null +++ b/doc/html/fusion/extension.html @@ -0,0 +1,556 @@ + + + +Extension + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The Fusion library is designed to be extensible, new sequences types can easily + be added. In fact, the library support for std::pair, + boost::array and MPL + sequences is entirely provided using the extension mechanism. +

+

+ The process for adding a new sequence type to Fusion is: +

+
    +
  1. + Enable the tag dispatching + mechanism used by Fusion for your sequence type +
  2. +
  3. + Design an iterator type for the sequence +
  4. +
  5. + Provide specialized behaviour for the intrinsic operations of the new Fusion + sequence +
  6. +
+

+ + Our example +

+

+ In order to illustrate enabling a new sequence type for use with Fusion, we + are going to use the type: +

+
+namespace example
+{
+    struct example_struct
+    {
+        std::string name;
+        int age;
+        example_struct(
+            const std::string& n,
+            int a)
+            : name(n), age(a)
+        {}
+    };
+}
+
+

+ We are going to pretend that this type has been provided by a 3rd party library, + and therefore cannot be modified. We shall work through all the necessary steps + to enable example_struct to + serve as an Associative + Sequence as described in the Quick + Start guide. +

+

+ + Enabling Tag Dispatching +

+

+ The Fusion extensibility mechanism uses tag + dispatching to call the correct code for a given sequence + type. In order to exploit the tag dispatching mechanism we must first declare + a new tag type for the mechanism to use. For example: +

+
+namespace boost { namespace fusion {
+    struct example_sequence_tag; // Only definition needed
+}}
+
+

+ Next we need to enable the traits::tag_of + metafunction to return our newly chosen tag type for operations involving our + sequence. This is done by specializing traits::tag_of + for our sequence type. +

+
+#include <boost/fusion/support/tag_of_fwd.hpp>
+
+namespace boost { namespace fusion { namespace traits {
+    
+    template<>
+    struct tag_of<example_struct>
+    {
+        typedef example_sequence_tag type;
+    };
+}}}
+
+

+ traits::tag_of also has a second template argument, + that can be used in conjuction with boost::enable_if + to provide tag support for whole clases of types. This feature is not necessary + for our sequence, but for an example see the code in: +

+
+#include <boost/fusion/sequence/adapted/mpl/tag_of.hpp>
+
+

+ + Designing a + suitable iterator +

+

+ We need an iterator to describe positions, and provide access to the data within + our sequence. As it is straightforward to do, we are going to provide a random + access iterator in our example. +

+

+ We will use a simple design, in which the 2 members of example_struct + are given numbered indices, 0 for name + and 1 for age respectively. +

+
+template<typename Struct, int Pos>
+struct example_struct_iterator
+    : iterator_base<example_struct_iterator<Struct, Pos> >
+{
+    BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
+    typedef Struct struct_type;
+    typedef mpl::int_<Pos> index;
+    typedef random_access_traversal_tag category;
+
+    example_struct_iterator(Struct& str)
+        : struct_(str) {}
+
+    Struct& struct_;
+};
+
+

+ A quick summary of the details of our iterator: +

+
    +
  1. + The iterator is parameterized by the type it is iterating over, and the index + of the current element. +
  2. +
  3. + The typedefs struct_type + and index provide convenient + access to information we will need later in the implementation. +
  4. +
  5. + The typedef category allows + the traits::category_of + metafunction to establish the traversal category of the iterator. +
  6. +
  7. + The constructor stores a reference to the example_struct + being iterated over. +
  8. +
+

+ We also need to enable tag + dispatching for our iterator type, with another specialization + of traits::tag_of: +

+
+namespace boost { namespace fusion {
+    struct example_struct_iterator_tag;
+
+    namespace traits
+    {
+        template<typename Struct, int Pos>
+        struct tag_of<boost::fusion::example_struct_iterator<Struct, Pos> >
+        {
+            typedef example_struct_iterator_tag type;
+        };
+    }
+}}
+
+

+ In isolation, the iterator implementation is pretty dry. Things should become + clearer as we add features to our implementation. +

+

+ + A first + couple of instructive features +

+

+ To start with, we will get the result_of::value_of metafunction working. To + do this, we provide a specialization of the boost::fusion::extension::value_of_impl + template for our iterator's tag type. +

+
+template<>
+struct value_of_impl<example_struct_iterator_tag>
+{
+    template<typename Iterator>
+    struct apply;
+
+    template<typename Struct>
+    struct apply<example_struct_iterator<Struct, 0> >
+    {
+        typedef std::string type;
+    };
+
+    template<typename Struct>
+    struct apply<example_struct_iterator<Struct, 1> >
+    {
+        typedef int type;
+    };
+};
+
+

+ The implementation itself is pretty simple, it just uses 2 partial specializations + to provide the type of the 2 different members of example_struct, + based on the index of the iterator. +

+

+ To understand how value_of_impl + is used by the library we will look at the implementation of value_of: +

+
+template <typename Iterator>
+struct value_of
+{
+    typedef typename
+        extension::value_of_impl<typename Iterator::ftag>::
+            template apply<Iterator>::type
+    type;
+};
+
+

+ So value_of + uses tag dispatching + to select an MPL Metafunction Class to provide its functionality. You will + notice this pattern throughout the implementation of Fusion. +

+

+ Ok, lets enable dereferencing of our iterator. In this case we must provide + a suitable specialization of deref_impl. +

+
+template<>
+struct deref_impl<example_struct_iterator_tag>
+{
+    template<typename Iterator>
+    struct apply;
+
+    template<typename Struct>
+    struct apply<example_struct_iterator<Struct, 0> >
+    {
+        typedef typename mpl::if_<
+            is_const<Struct>, std::string const&, std::string&>::type type;
+
+        static type
+        call(example_struct_iterator<Struct, 0> const& it)
+        {
+            return it.struct_.name;
+        }
+    };
+
+    template<typename Struct>
+    struct apply<example_struct_iterator<Struct, 1> >
+    {
+        typedef typename mpl::if_<
+            is_const<Struct>, int const&, int&>::type type;
+
+        static type
+        call(example_struct_iterator<Struct, 1> const& it)
+        {
+            return it.struct_.age;
+        }
+    };
+};
+
+

+ The use of deref_impl is very + similar to that of value_of_impl, + but it also provides some runtime functionality this time via the call static member function. To see how + deref_impl is used, lets have + a look at the implementation of deref: +

+
+namespace result_of
+{
+    template <typename Iterator>
+    struct deref
+    {
+        typedef typename
+            deref_impl<typename Iterator::ftag>::
+                template apply<Iterator>::type
+        type;
+    };
+}
+
+template <typename Iterator>
+typename result_of::deref<Iterator>::type
+deref(Iterator const& i)
+{
+    typename result_of::deref<Iterator>::type result =
+        extension::deref_impl<typename Iterator::ftag>::
+            template apply<Iterator>::call(i);
+    return result;
+}
+
+

+ So again result_of::deref uses tag + dispatching in exactly the same way as the value_of implementation. The runtime + functionality used by deref is provided by the call static function of the selected MPL + Metafunction Class. +

+

+ The actual implementation of deref_impl + is slightly more complex than that of value_of_impl. + We also need to implement the call + function, which returns a reference to the appropriate member of the underlying + sequence. We also require a little bit of metaprogramming to return const references if the underlying sequence + is const. +

+
+ + + + + +
[Note]Note

+ Although there is a fair amount of left to do to produce a fully fledged + Fusion sequence, value_of and deref illustrate all the signficant + concepts required. The remainder of the process is very repetitive, simply + requiring implementation of a suitable xxxx_impl + for each feature xxxx. +

+

+ + Implementing + the remaining iterator functionality +

+

+ Ok, now we have seen the way value_of and deref work, everything else will work + in pretty much the same way. Lets start with forward iteration, by providing + a next_impl: +

+
+template<>
+struct next_impl<example_struct_iterator_tag>
+{
+    template<typename Iterator>
+    struct apply
+    {
+        typedef typename Iterator::struct_type struct_type;
+        typedef typename Iterator::index index;
+        typedef example_struct_iterator<struct_type, index::value + 1> type;
+
+        static type
+        call(Iterator const& i)
+        {
+            return type(i.struct_);
+        }
+    };
+};
+
+

+ This should be very familiar from our deref_impl + implementation, we will be using this approach again and again now. Our design + is simply to increment the index + counter to move on to the next element. The various other iterator manipulations + we need to perform will all just involve simple calculations with the index variables. +

+

+ We also need to provide a suitable equal_to_impl + so that iterators can be correctly compared. A Bidirectional + Iterator will also need an implementation of prior_impl. + For a Random + Access Iterator distance_impl + and advance_impl also need + to be provided in order to satisfy the necessary complexity guarantees. As + our iterator is a Random + Access Iterator we will have to implement all of these functions. +

+

+ Full implementations of prior_impl, + advance_impl, distance_impl and equal_to_impl + are provided in the example code. +

+

+ + Implementing + the intrinsic functions of the sequence +

+

+ In order that Fusion can correctly identify our sequence as a Fusion sequence, + we need to enable is_sequence + for our sequence type. As usual we just create an impl + type specialized for our sequence tag: +

+
+template<>
+struct is_sequence_impl<example_sequence_tag>
+{
+    template<typename T>
+    struct apply : mpl::true_ {};
+};
+
+

+ We've some similar formalities to complete, providing category_of_impl + so Fusion can correctly identify our sequence type, and is_view_impl + so Fusion can correctly identify our sequence as not being a View + type. Implementations are provide in the example code. +

+

+ Now we've completed some formalities, on to more interesting features. Lets + get begin working so that we can get an + iterator to start accessing the data in our sequence. +

+
+template<>
+struct begin_impl<example_sequence_tag>
+{
+    template<typename Sequence>
+    struct apply
+    {
+        typedef example_struct_iterator<Sequence, 0> type;
+
+        static type
+        call(Sequence& seq)
+        {
+            return type(seq);
+        }
+    };
+};
+
+

+ The implementation uses the same ideas we have applied throughout, in this + case we are just creating one of the iterators we developed earlier, pointing + to the first element in the sequence. The implementation of end is very similar, and is provided + in the example code. +

+

+ For our Random + Access Sequence we will also need to implement size_impl, + value_at_impl and at_impl. +

+

+ + Enabling + our type as an associative container +

+

+ In order for example_struct + to serve as an associative container, we need to enable 3 lookup features, + at_key, value_at_key and has_key. We also need to provide an + implementation of the is_associative + trait so that our sequence can be correctly identified as an associative container. +

+

+ To implement at_key_impl we + need to associate the fields::age and + fields::age types described in the Quick + Start guide with the appropriate members of example_struct. + Our implementation is as follows: +

+
+template<>
+struct at_key_impl<example_sequence_tag>
+{
+    template<typename Sequence, typename Key>
+    struct apply;
+
+    template<typename Sequence>
+    struct apply<Sequence, fields::name>
+    {
+        typedef typename mpl::if_<
+            is_const<Sequence>,
+            std::string const&,
+            std::string&>::type type;
+
+        static type
+        call(Sequence& seq)
+        {
+            return seq.name;
+        };
+    };
+
+    template<typename Sequence>
+    struct apply<Sequence, fields::age>
+    {
+        typedef typename mpl::if_<
+            is_const<Sequence>,
+            int const&,
+            int&>::type type;
+
+        static type
+        call(Sequence& seq)
+        {
+            return seq.age;
+        };
+    };
+};
+
+

+ Its all very similar to the implementations we've seen previously, such as + deref_impl and value_of_impl. Instead of identifying the + members by index or position, we are now selecting them using the types fields::name and fields::age. The + implementations of value_at_key_impl + and has_key_impl are equally + straightforward, and are provided in the example code, along with an implementation + of is_associative_impl. +

+

+ + Summary +

+

+ We've now worked through the entire process for adding a new random access + sequence and we've also enabled our type to serve as an associative container. + The implementation was slightly longwinded, but followed a simple repeating + pattern. +

+

+ The support for std::pair, MPL + sequences, and boost::array all use the same approach, and provide + additional examples of the approach for a variety of types. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/introduction.html b/doc/html/fusion/introduction.html new file mode 100644 index 00000000..9feadd71 --- /dev/null +++ b/doc/html/fusion/introduction.html @@ -0,0 +1,139 @@ + + + +Introduction + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ An advantage other languages such as Python and Lisp/ Scheme, ML and Haskell, + etc., over C++ is the ability to have heterogeneous containers that can hold + arbitrary element types. All the containers in the standard library can only + hold a specific type. A vector<int> + can only hold ints. A list<X> can + only hold elements of type X, + and so on. +

+

+ True, you can use inheritance to make the containers hold different types, + related through subclassing. However, you have to hold the objects through + a pointer or smart reference of some sort. Doing this, you'll have to rely + on virtual functions to provide polymorphic behavior since the actual type + is erased as soon as you store a pointer to a derived class to a pointer to + its base. The held objects must be related: you cannot hold objects of unrelated + types such as char, int, class X, float, + etc. Oh sure you can use something like Boost.Any + to hold arbitrary types, but then you pay more in terms of runtime costs and + due to the fact that you practically erased all type information, you'll have + to perform dangerous casts to get back the original type. +

+

+ The Boost.Tuple + library written by Jaakko + Jarvi provides heterogeneous containers in C++. The tuple + is a basic data structure that can hold heterogeneous types. It's a good first + step, but it's not complete. What's missing are the algorithms. It's nice that + we can store and retrieve data to and from tuples, pass them around as arguments + and return types. As it is, the Boost.Tuple + facility is already very useful. Yet, as soon as you use it more often, usage + patterns emerge. Eventually, you collect these patterns into algorithm libraries. +

+

+ Hmmm, kinda reminds us of STL right? Right! Can you imagine how it would be + like if you used STL without the algorithms? Everyone will have to reinvent + their own algorithm wheels. +

+

+ Fusion is a library and a framework similar to both STL + and the boost MPL. + The structure is modeled after MPL, + which is modeled after STL. + It is named "fusion" because the library is reminiscent of the "fusion" + of compile time meta-programming with runtime programming. The library inherently + has some interesting flavors and characteristics of both MPL + and STL. + It lives in the twilight zone between compile time meta-programming and run + time programming. STL + containers work on values. MPL containers work on types. Fusion containers + work on both types and values. +

+

+ Unlike MPL, Fusion + algorithms are lazy and non sequence-type preserving. What does that mean? + It means that when you operate on a sequence through a Fusion algorithm that + returns a sequence, the sequence returned may not be of the same class as the + original. This is by design. Runtime efficiency is given a high priority. Like + MPL, and unlike + STL, + fusion algorithms are functional in nature such that algorithms are non mutating + (no side effects). However, due to the high cost of returning full sequences + such as vectors and lists, Views are returned from Fusion + algorithms instead. For example, the transform algorithm does not actually + return a transformed version of the original sequence. transform returns a transform_view. This view holds a + reference to the original sequence plus the transform function. Iteration over + the transform_view + will apply the transform function over the sequence elements on demand. This + lazy evaluation scheme allows us to chain as many algorithms + as we want without incurring a high runtime penalty. +

+

+ The lazy evaluation scheme where algorithms return views + allows operations such as push_back to be totally generic. In + Fusion, push_back is actually a generic algorithm + that works on all sequences. Given an input sequence s + and a value x, Fusion's push_back algorithm simply returns + a joint_view: + a view that holds a reference to the original sequence s + and the value x. Functions + that were once sequence specific and need to be implemented N times over N + different sequences are now implemented only once. +

+

+ Fusion provides full round compatibility with MPL. + Fusion sequences are fully conforming MPL + sequences and MPL + sequences are fully compatible with Fusion. You can work with Fusion sequences + on MPL if you + wish to work solely on types. In MPL, + Fusion sequences follow MPL's + sequence-type preserving semantics (i.e. algorithms preserve the original sequence + type. e.g. transforming a vector returns a vector). You can also convert from + an MPL sequence + to a Fusion sequence. For example, there are times when it is convenient to + work solely on MPL + using pure MPL + sequences, then, convert them to Fusion sequences as a final step before actual + instantiation of real runtime objects with data. You have the best of both + worlds. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators.html b/doc/html/fusion/iterators.html new file mode 100644 index 00000000..2678a48b --- /dev/null +++ b/doc/html/fusion/iterators.html @@ -0,0 +1,59 @@ + + + +Iterators + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Like MPL and + STL, + iterators are a fundamental concept in Fusion. As with MPL + and STL + iterators describe positions, and provide access to data within an underlying + Sequence. +

+

+ + Header +

+
+#include <boost/fusion/iterator.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/concepts.html b/doc/html/fusion/iterators/concepts.html new file mode 100644 index 00000000..303291b2 --- /dev/null +++ b/doc/html/fusion/iterators/concepts.html @@ -0,0 +1,60 @@ + + + +Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion iterators are divided into different traversal categories. Forward + Iterator is the most basic concept. Bidirectional + Iterator is a refinement of Forward + Iterator. Random + Access Iterator is a refinement of Bidirectional + Iterator. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/concepts/bidirectional_iterator.html b/doc/html/fusion/iterators/concepts/bidirectional_iterator.html new file mode 100644 index 00000000..7545c3a0 --- /dev/null +++ b/doc/html/fusion/iterators/concepts/bidirectional_iterator.html @@ -0,0 +1,245 @@ + + + +Bidirectional + Iterator + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Bidirectional Iterator traverses a Sequence + allowing movement in either direction one element at a time. +

+
+

Notation

+
+
i
+
+ A Bidirectional Iterator +
+
I
+
+ A Bidirectional Iterator type +
+
M
+
+ An MPL + integral constant +
+
N
+
+ An integral constant +
+
+
+
+ + Refinement + of +
+

+ Forward Iterator +

+
+ + Expression + requirements +
+

+ In addition to the requirements defined in Forward + Iterator, the following expressions must be valid: +

+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeRuntime + Complexity
next(i)Bidirectional + IteratorConstant
prior(i)Bidirectional + IteratorConstant
advance_c<N>(i)Bidirectional + IteratorConstant
advance<M>(i)Bidirectional + IteratorConstant
+
+
+ + Meta + Expressions +
+
+

+ +

+ ++++ + + + + + + + + +
ExpressionCompile Time Complexity
result_of::prior<I>::typeAmortized constant + time
+
+
+ + Expression + Semantics +
+

+ The semantics of an expression are defined only where they differ from, + or are not defined in Forward + Iterator +

+
+

+ +

+ ++++ + + + + + + + + +
ExpressionSemantics
prior(i)An + iterator to the element preceding i +
+
+
+ + Invariants +
+

+ In addition to the invariants of Forward + Iterator, the following invariants always hold: +

+
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/concepts/forward_iterator.html b/doc/html/fusion/iterators/concepts/forward_iterator.html new file mode 100644 index 00000000..5a37ee11 --- /dev/null +++ b/doc/html/fusion/iterators/concepts/forward_iterator.html @@ -0,0 +1,353 @@ + + + +Forward + Iterator + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Forward Iterator traverses a Sequence + allowing movement in only one direction through it's elements, one element + at a time. +

+
+

Notation

+
+
i, + j
+
+ Forward Iterators +
+
I, + J
+
+ Forward Iterator types +
+
M
+
+ An MPL + integral constant +
+
N
+
+ An integral constant +
+
+
+
+ + Expression + requirements +
+

+ A type models Forward Iterator if, in addition to being CopyConstructable, + the following expressions are valid: +

+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeRuntime + Complexity
next(i)Forward IteratorConstant
i == jConvertible to + boolConstant
i != jConvertible to + boolConstant
advance_c<N>(i)Forward IteratorConstant
advance<M>(i)Forward IteratorConstant
distance(i, j)result_of::distance<I, J>::typeConstant
deref(i)result_of::deref<I>::typeConstant
*iresult_of::deref<I>::typeConstant
+
+
+ + Meta + Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::next<I>::typeAmortized constant + time
result_of::equal_to<I, J>::typeAmortized constant + time
result_of::advance_c<I, N>::typeLinear
result_of::advance<I ,M>::typeLinear
result_of::distance<I ,J>::typeLinear
result_of::deref<I>::typeAmortized constant + time
result_of::value_of<I>::typeAmortized constant + time
+
+
+ + Expression + Semantics +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
next(i)An + iterator to the element following i +
i == jIterator equality + comparison
i != jIterator inequality + comparison
advance_c<N>(i)An + iterator n elements after i + in the sequence
advance<M>(i)Equivalent + to advance_c<M::value>(i) +
distance(i, j)The + number of elements between i + and j +
deref(i)The + element at positioni +
*iEquivalent + to deref(i) +
+
+
+ + Invariants +
+

+ The following invariants always hold: +

+
    +
  • !(i == j) == (i != j)
  • +
  • next(i) == advance_c<1>(i)
  • +
  • distance(i, advance_c<N>(i)) == N
  • +
  • + Using next to traverse the + sequence will never return to a previously seen position +
  • +
  • +deref(i) + is equivalent to *i +
  • +
  • + If i == j then *i is equivalent to *j +
  • +
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/concepts/random_access_iterator.html b/doc/html/fusion/iterators/concepts/random_access_iterator.html new file mode 100644 index 00000000..a348d272 --- /dev/null +++ b/doc/html/fusion/iterators/concepts/random_access_iterator.html @@ -0,0 +1,216 @@ + + + +Random + Access Iterator + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Random Access Iterator traverses a Sequence + moving in either direction, permitting efficient arbitrary distance movements + back and forward through the sequence. +

+
+

Notation

+
+
i, + j
+
+ Random Access Iterators +
+
I, + J
+
+ Random Access Iterator types +
+
M
+
+ An MPL + integral constant +
+
N
+
+ An integral constant +
+
+
+
+ + Refinement + of +
+

+ Bidirectional + Iterator +

+
+ + Expression + requirements +
+

+ In addition to the requirements defined in Bidirectional + Iterator, the following expressions must be valid: +

+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeRuntime + Complexity
next(i)Random + Access IteratorConstant
prior(i)Random + Access IteratorConstant
advance_c<N>(i)Random + Access IteratorConstant
advance<M>(i)Random + Access IteratorConstant
+
+
+ + Meta + Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::advance_c<I, N>::typeAmortized constant + time
result_of::advance<I, M>::typeAmortized constant + time
result_of::distance<I ,J>::typeAmortized constant + time
+
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions.html b/doc/html/fusion/iterators/functions.html new file mode 100644 index 00000000..cad3aa28 --- /dev/null +++ b/doc/html/fusion/iterators/functions.html @@ -0,0 +1,52 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion provides functions for manipulating iterators, analogous to the similar + functions from the MPL + library. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/advance.html b/doc/html/fusion/iterators/functions/advance.html new file mode 100644 index 00000000..e8af4632 --- /dev/null +++ b/doc/html/fusion/iterators/functions/advance.html @@ -0,0 +1,129 @@ + + + +advance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator by a specified distance. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename M
+    >
+typename result_of::advance<I, M>::type advance(I const& i); 
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Forward + Iterator +Iterator to move relative to
NAn + MPL Integral ConstantNumber of positions to move
+
+
+ + Expression + Semantics +
+
+advance<M>(i);
+
+

+ Return type: A model of the same iterator + concept as i. +

+

+ Semantics: Returns an iterator to the + element M positions from + i. If i + is a Bidirectional + Iterator then M + may be negative. +

+
+ + Header +
+
+#include <boost/fusion/iterator/advance.hpp>
+
+
+ + Example +
+
+typedef vector<int,int,int> vec;
+
+vec v(1,2,3);
+assert(deref(advance<mpl::int_<2> >(begin(v))) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/advance_c.html b/doc/html/fusion/iterators/functions/advance_c.html new file mode 100644 index 00000000..ba10b387 --- /dev/null +++ b/doc/html/fusion/iterators/functions/advance_c.html @@ -0,0 +1,129 @@ + + + +advance_c + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator by a specified distance. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    int N
+    >
+typename result_of::advance_c<I, N>::type advance_c(I const& i); 
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Forward + Iterator +Iterator to move relative to
NInteger + constantNumber of positions to move
+
+
+ + Expression + Semantics +
+
+advance_c<N>(i);
+
+

+ Return type: A model of the same iterator + concept as i. +

+

+ Semantics: Returns an iterator to the + element N positions from + i. If i + is a Bidirectional + Iterator then N + may be negative. +

+
+ + Header +
+
+#include <boost/fusion/iterator/advance.hpp>
+
+
+ + Example +
+
+typedef vector<int,int,int> vec;
+
+vec v(1,2,3);
+assert(deref(advance_c<2>(begin(v))) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/deref.html b/doc/html/fusion/iterators/functions/deref.html new file mode 100644 index 00000000..122f836f --- /dev/null +++ b/doc/html/fusion/iterators/functions/deref.html @@ -0,0 +1,117 @@ + + + +deref + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Deferences an iterator. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+typename result_of::deref<I>::type deref(I const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+deref(i);
+
+

+ Return type: result_of::deref<I>::type +

+

+ Semantics: Dereferences the iterator + i. +

+
+ + Header +
+
+#include <boost/fusion/iterator/deref.hpp>
+
+
+ + Example +
+
+typedef vector<int,int&> vec;
+
+int i(0);
+vec v(1,i);
+assert(deref(begin(v)) == 1);
+assert(deref(next(begin(v))) == 0);
+assert(&(deref(next(begin(v)))) == &i);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/distance.html b/doc/html/fusion/iterators/functions/distance.html new file mode 100644 index 00000000..5c85af91 --- /dev/null +++ b/doc/html/fusion/iterators/functions/distance.html @@ -0,0 +1,116 @@ + + + +distance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the distance between 2 iterators. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename J
+    >
+typename result_of::distance<I, J>::type distance(I const& i, J const& j);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+i, j +Models of Forward Iterator + into the same sequenceThe start and end points of + the distance to be measured
+
+
+ + Expression + Semantics +
+
+distance(i,j);
+
+

+ Return type: int +

+

+ Semantics: Returns the distance between + iterators i and j. +

+
+ + Header +
+
+#include <boost/fusion/iterator/distance.hpp>
+
+
+ + Example +
+
+typedef vector<int,int,int> vec;
+
+vec v(1,2,3);
+assert(distance(begin(v), next(next(begin(v)))) == 2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/next.html b/doc/html/fusion/iterators/functions/next.html new file mode 100644 index 00000000..d13a55fa --- /dev/null +++ b/doc/html/fusion/iterators/functions/next.html @@ -0,0 +1,117 @@ + + + +next + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator 1 position forwards. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+typename result_of::next<I>::type next(I const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+next(i);
+
+

+ Return type: A model of the same iterator + concept as i. +

+

+ Semantics: Returns an iterator to the + next element after i. +

+
+ + Header +
+
+#include <boost/fusion/iterator/next.hpp>
+
+
+ + Example +
+
+typedef vector<int,int,int> vec;
+
+vec v(1,2,3);
+assert(deref(begin(v)) == 1);
+assert(deref(next(begin(v))) == 2);
+assert(deref(next(next(begin(v)))) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/functions/prior.html b/doc/html/fusion/iterators/functions/prior.html new file mode 100644 index 00000000..5404fe5c --- /dev/null +++ b/doc/html/fusion/iterators/functions/prior.html @@ -0,0 +1,116 @@ + + + +prior + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator 1 position backwards. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+typename result_of::prior<I>::type prior(I const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Bidirectional + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+prior(i);
+
+

+ Return type: A model of the same iterator + concept as i. +

+

+ Semantics: Returns an iterator to the + element prior to i. +

+
+ + Header +
+
+#include <boost/fusion/iterator/prior.hpp>
+
+
+ + Example +
+
+typedef vector<int,int> vec;
+
+vec v(1,2);
+assert(deref(next(begin(v))) == 2);
+assert(deref(prior(next(begin(v)))) == 1);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions.html b/doc/html/fusion/iterators/metafunctions.html new file mode 100644 index 00000000..9f4cbefe --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions.html @@ -0,0 +1,49 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/advance.html b/doc/html/fusion/iterators/metafunctions/advance.html new file mode 100644 index 00000000..20ac0866 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/advance.html @@ -0,0 +1,133 @@ + + + +advance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator a specified distance. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename M
+    >
+struct advance
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Forward + Iterator +Iterator to move relative to
MModel + of MPL Integral ConstantNumber of positions to move
+
+
+ + Expression + Semantics +
+
+result_of::advance<I,M>::type
+
+

+ Return type: A model of the same iterator + concept as I. +

+

+ Semantics: Returns an iterator a distance + M from I. + If I is a Bidirectional + Iterator then M + may be negative. +

+
+ + Header +
+
+#include <boost/fusion/iterator/advance.hpp>
+
+
+ + Example +
+
+typedef vector<int,double,char> vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::next<first>::type second;
+typedef result_of::next<second>::type third;
+
+BOOST_MPL_ASSERT((result_of::equal_to<result_of::advance<first, boost::mpl::int_<2> >::type, third>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/advance_c.html b/doc/html/fusion/iterators/metafunctions/advance_c.html new file mode 100644 index 00000000..322888b2 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/advance_c.html @@ -0,0 +1,133 @@ + + + +advance_c + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Moves an iterator by a specified distance. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    int N
+    >
+struct advance_c
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Forward + Iterator +Iterator to move relative to
NInteger + constantNumber of positions to move
+
+
+ + Expression + Semantics +
+
+result_of::advance_c<I, N>::type
+
+

+ Return type: A model of the same iterator + concept as I. +

+

+ Semantics: Returns an iterator a distance + N from I. + If I is a Bidirectional + Iterator then N + may be negative. Equivalent to result_of::advance<I, boost::mpl::int_<N> >::type. +

+
+ + Header +
+
+#include <boost/fusion/iterator/advance.hpp>
+
+
+ + Example +
+
+typedef vector<int,double,char> vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::next<first>::type second;
+typedef result_of::next<second>::type third;
+
+BOOST_MPL_ASSERT((result_of::equal_to<result_of::advance_c<first, 2>::type, third>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/deref.html b/doc/html/fusion/iterators/metafunctions/deref.html new file mode 100644 index 00000000..f25478d6 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/deref.html @@ -0,0 +1,123 @@ + + + +deref + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the type that will be returned by dereferencing an iterator. +

+
+ + Synposis +
+
+template<
+    typename I
+    >
+struct deref
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::deref<I>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the result of dereferencing + an iterator of type I. +

+
+ + Header +
+
+#include <boost/fusion/iterator/deref.hpp>
+
+
+ + Example +
+
+typedef vector<int,int&> vec;
+typedef const vec const_vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::next<first>::type second;
+
+typedef result_of::begin<const_vec>::type const_first;
+typedef result_of::next<const_first>::type const_second;
+
+BOOST_MPL_ASSERT((boost::is_same<result_of::deref<first>::type, int&>));
+BOOST_MPL_ASSERT((boost::is_same<result_of::deref<second>::type, int&>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/distance.html b/doc/html/fusion/iterators/metafunctions/distance.html new file mode 100644 index 00000000..33035d44 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/distance.html @@ -0,0 +1,123 @@ + + + +distance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the distance between two iterators. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename J
+    >
+struct distance
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+I, J +Models of Forward Iterator + into the same sequenceThe start and end points of + the distance to be measured
+
+
+ + Expression + Semantics +
+
+result_of::distance<I, J>::type
+
+

+ Return type: A model of MPL Integral Constant. +

+

+ Semantics: Returns the distance between + iterators of types I and + J. +

+
+ + Header +
+
+#include <boost/fusion/iterator/distance.hpp>
+
+
+ + Example +
+
+typedef vector<int,double,char> vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::next<first>::type second;
+typedef result_of::next<second>::type third;
+typedef result_of::distance<first,third>::type dist;
+
+BOOST_MPL_ASSERT_RELATION(dist::value, ==, 2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/equal_to.html b/doc/html/fusion/iterators/metafunctions/equal_to.html new file mode 100644 index 00000000..e7e34a05 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/equal_to.html @@ -0,0 +1,120 @@ + + + +equal_to + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a true-valued MPL Integral Constant if I + and J are equal. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename J
+    >
+struct equal_to
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+I, J +Any fusion iteratorsOperation's + arguments
+
+
+ + Expression + Semantics +
+
+result_of::equal_to<I, J>::type
+
+

+ Return type: A model of MPL Integral Constant. +

+

+ Semantics: Returns boost::mpl::true_ + if I and J are iterators to the same position. + Returns boost::mpl::false_ otherwise. +

+
+ + Header +
+
+#include <boost/fusion/iterator/equal_to.hpp>
+
+
+ + Example +
+
+typedef vector<int,double> vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::end<vec>::type last;
+BOOST_MPL_ASSERT((result_of::equal_to<first, first>));
+BOOST_MPL_ASSERT_NOT((result_of::equal_to<first,last>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/next.html b/doc/html/fusion/iterators/metafunctions/next.html new file mode 100644 index 00000000..9d0aa196 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/next.html @@ -0,0 +1,118 @@ + + + +next + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the type of the next iterator in a sequence. +

+
+ + Synposis +
+
+template<
+    typename I
+    >
+struct next
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::next<I>::type
+
+

+ Return type: A model of the same iterator + concept as I. +

+

+ Semantics: Returns an iterator to the + next element in the sequence after I. +

+
+ + Header +
+
+#include <boost/fusion/iterator/next.hpp>
+
+
+ + Example +
+
+typedef vector<int,double> vec;
+typedef result_of::next<result_of::begin<vec>::type>::type second;
+
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<second>::type, double>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/prior.html b/doc/html/fusion/iterators/metafunctions/prior.html new file mode 100644 index 00000000..577864f9 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/prior.html @@ -0,0 +1,121 @@ + + + +prior + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the type of the previous iterator in a sequence. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+struct prior
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Bidirectional + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::prior<I>::type
+
+

+ Return type: A model of the same iterator + concept as I. +

+

+ Semantics: Returns an iterator to the + previous element in the sequence before I. +

+
+ + Header +
+
+#include <boost/fusion/iterator/prior.hpp>
+
+
+ + Example +
+
+typedef vector<int,double> vec;
+typedef result_of::next<result_of::begin<vec>::type>::type second;
+
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<second>::type, double>));
+
+typedef result_of::prior<second>::type first;
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<first>::type, int>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/metafunctions/value_of.html b/doc/html/fusion/iterators/metafunctions/value_of.html new file mode 100644 index 00000000..75f07033 --- /dev/null +++ b/doc/html/fusion/iterators/metafunctions/value_of.html @@ -0,0 +1,121 @@ + + + +value_of + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the type stored at the position of an iterator. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+struct value_of
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
IModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+result_of::value_of<I>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the type stored in + a sequence at iterator position I. +

+
+ + Header +
+
+#include <boost/fusion/iterator/value_of.hpp>
+
+
+ + Example +
+
+typedef vector<int,int&,const int&> vec;
+typedef result_of::begin<vec>::type first;
+typedef result_of::next<first>::type second;
+typedef result_of::next<second>::type third;
+
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<first>::type, int>));
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<second>::type, int&>));
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<third>::type, const int&>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/operators.html b/doc/html/fusion/iterators/operators.html new file mode 100644 index 00000000..707d5964 --- /dev/null +++ b/doc/html/fusion/iterators/operators.html @@ -0,0 +1,51 @@ + + + +Operators + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Overloaded operators are provided to provide a more natural syntax for dereferencing + iterators, and comparing them for equality. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/operators/operator_equality.html b/doc/html/fusion/iterators/operators/operator_equality.html new file mode 100644 index 00000000..a786fe8d --- /dev/null +++ b/doc/html/fusion/iterators/operators/operator_equality.html @@ -0,0 +1,110 @@ + + + + Operator + == + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Compares 2 iterators for equality. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename J
+    >
+unspecified operator==(I const& i, J const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+i, j +Any fusion iteratorsOperation's + arguments
+
+
+ + Expression + Semantics +
+
+i == j
+
+

+ Return type: Convertible to bool. +

+

+ Semantics: Equivalent to result_of::equal_to<I,J>::value + where I and J are the types of i + and j respectively. +

+
+ + Header +
+
+#include <boost/fusion/iterator/equal_to.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/operators/operator_inequality.html b/doc/html/fusion/iterators/operators/operator_inequality.html new file mode 100644 index 00000000..2ad8299f --- /dev/null +++ b/doc/html/fusion/iterators/operators/operator_inequality.html @@ -0,0 +1,106 @@ + + + + Operator + != + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Compares 2 iterators for inequality. +

+
+ + Synopsis +
+
+template<
+    typename I,
+    typename J
+    >
+unspecified operator==(I const& i, J const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
+i, j +Any fusion iteratorsOperation's + arguments
+
+
+ + Expression + Semantics +
+

+ Return type: Convertible to bool. +

+

+ Semantics: Equivalent to !result_of::equal_to<I,J>::value + where I and J are the types of i + and j respectively. +

+
+ + Header +
+
+#include <boost/fusion/iterator/equal_to.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/iterators/operators/operator_unary_star.html b/doc/html/fusion/iterators/operators/operator_unary_star.html new file mode 100644 index 00000000..4b719f69 --- /dev/null +++ b/doc/html/fusion/iterators/operators/operator_unary_star.html @@ -0,0 +1,121 @@ + + + + Operator + * + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Dereferences an iterator. +

+
+ + Synopsis +
+
+template<
+    typename I
+    >
+typename result_of::deref<I>::type operator*(unspecified<I> const& i);
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
iModel + of Forward + Iterator +Operation's argument
+
+
+ + Expression + Semantics +
+
+*i
+
+

+ Return type: Equivalent to the return + type of deref(i). +

+

+ Semantics: Equivalent to deref(i). +

+
+ + Header +
+
+#include <boost/fusion/iterator/deref.hpp>
+
+
+ + Example +
+
+typedef vector<int,int&> vec;
+
+int i(0);
+vec v(1,i);
+assert(*begin(v) == 1);
+assert(*next(begin(v)) == 0);
+assert(&(*next(begin(v))) == &i);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/notes.html b/doc/html/fusion/notes.html new file mode 100644 index 00000000..b1987d63 --- /dev/null +++ b/doc/html/fusion/notes.html @@ -0,0 +1,254 @@ + + + +Notes + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Recursive Inlined + Functions +

+

+ An interesting peculiarity of functions like at when applied to a Forward + Sequence like list is that what could have been + linear runtime complexity effectively becomes constant O(1) due to compiler + optimization of C++ inlined functions, however deeply recursive (up to a certain + compiler limit of course). Compile time complexity remains linear. +

+

+ + Overloaded Functions +

+

+ Associative sequences use function overloading to implement membership testing + and type associated key lookup. This amounts to constant runtime and amortized + constant compile time complexities. There is an overloaded function, f(k), for each key type k. The compiler chooses the appropriate function + given a key, k. +

+

+ + Tag Dispatching +

+

+ Tag dispatching is a generic programming technique for selecting template specializations. + There are typically 3 components involved in the tag dispatching mechanism: +

+
    +
  1. + A type for which an appropriate template specialization is required +
  2. +
  3. + A metafunction that associates the type with a tag type +
  4. +
  5. + A template that is specialized for the tag type +
  6. +
+

+ For example, the fusion result_of::begin metafunction + is implemented as follows: +

+
+template <typename Sequence>
+struct begin
+{
+    typedef typename
+        result_of::begin_impl<typename traits::tag_of<Sequence>::type>::
+        template apply<Sequence>::type
+    type;
+};
+
+

+ In the case: +

+
    +
  1. +Sequence is the type for + which a suitable implementation of result_of::begin_impl + is required +
  2. +
  3. +traits::tag_of is the metafunction that associates + Sequence with an appropriate + tag +
  4. +
  5. +result_of::begin_impl is the template which is specialized + to provide an implementation for each tag type +
  6. +
+

+ + Extensibility +

+

+ Unlike MPL, there + is no extensibe sequence concept in fusion. This does not mean that Fusion + sequences are not extensible. In fact, all Fusion sequences are inherently + extensible. It is just that the manner of sequence extension in Fusion is diferent + from both STL + and MPL on account + of the lazy nature of fusion Algorithms. + STL + containers extend themselves in place though member functions such as push_back and insert. MPL + sequences, on the other hand, are extended through "intrinsic" functions + that actually return whole sequences. MPL + is purely functional and can not have side effects. For example, MPL's + push_back does not actually + mutate an mpl::vector. It can't do that. Instead, it returns + an extended mpl::vector. +

+

+ Like MPL, Fusion + too is purely functional and can not have side effects. With runtime efficiency + in mind, Fusion sequences are extended through generic functions that return + Views. Views + are sequences that do not actually contain data, but instead impart an alternative + presentation over the data from one or more underlying sequences. Views + are proxies. They provide an efficient yet purely functional way to work on + potentially expensive sequence operations. For example, given a vector, Fusion's push_back returns a joint_view, instead of an actual extended + vector. + A joint_view + holds a reference to the original sequence plus the appended data --making + it very cheap to pass around. +

+

+ + Element Conversion +

+

+ Functions that take in elemental values to form sequences (e.g. make_list) convert their arguments + to something suitable to be stored as a sequence element. In general, the element + types are stored as plain values. Example: +

+
+make_list(1, 'x')
+
+

+ returns a list<int, char>. +

+

+ There are a few exceptions, however. +

+

+ Arrays: +

+

+ Array arguments are deduced to reference to const types. For example + [14] + : +

+
+make_list("Donald", "Daisy")
+
+

+ creates a list + of type +

+
+list<const char (&)[7], const char (&)[6]>
+
+

+ Function pointers: +

+

+ Function pointers are deduced to the plain non-reference type (i.e. to plain + function pointer). Example: +

+
+void f(int i);
+  ...
+make_list(&f);
+
+

+ creates a list + of type +

+
+list<void (*)(int)>
+
+

+ + boost::ref +

+

+ Fusion's generation functions (e.g. make_list) by default stores the element + types as plain non-reference types. Example: +

+
+void foo(const A& a, B& b) {
+    ...
+    make_list(a, b)
+
+

+ creates a list + of type +

+
+list<A, B>
+
+

+ Sometimes the plain non-reference type is not desired. You can use boost::ref + and boost::cref to store references or const references + (respectively) instead. The mechanism does not compromise const correctness + since a const object wrapped with ref results in a tuple element with const + reference type (see the fifth code line below). Examples: +

+

+ For example: +

+
+A a; B b; const A ca = a;
+make_list(cref(a), b);          // creates list<const A&, B>
+make_list(ref(a), b);           // creates list<A&, B>
+make_list(ref(a), cref(b));     // creates list<A&, const B&>
+make_list(cref(ca));            // creates list<const A&>
+make_list(ref(ca));             // creates list<const A&>
+
+

+ See Boost.Ref for + details. +

+
+

+

[14] + Note that the type of a string literal is an array of const characters, + not const char*. To get make_list to create a list with an element of a non-const + array type one must use the ref + wrapper (see boost::ref). +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/organization.html b/doc/html/fusion/organization.html new file mode 100644 index 00000000..3e75a427 --- /dev/null +++ b/doc/html/fusion/organization.html @@ -0,0 +1,198 @@ + + + +Organization + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The library is organized into layers of modules, with each module addressing + a particular area of responsibility. A module may not depend on modules in + higher layers. +

+

+ The library is organized in three layers: +

+

+ + Layers +

+

+ fusion_org +

+

+ The entire library is found in the "boost/fusion" directory. Modules + are organized in directories. Each module has its own header file placed in + the same directory with the actual module-directory. For example, there exists + "boost/fusion/support.hpp" in the same directory as "boost/fusion/support". + Everything, except those found inside "detail" directories, is public. + The library is header-only. There is no need to build object files to link + against. +

+

+ + Directory +

+
    +
  • + tuple +
  • +
  • + algorithm +
      +
    • + iteration +
    • +
    • + query +
    • +
    • + transformation +
    • +
    +
  • +
  • + sequence +
      +
    • + adapted +
        +
      • + array +
      • +
      • + mpl +
      • +
      • + std_pair +
      • +
      +
    • +
    • + comparison +
    • +
    • + container +
        +
      • + list +
      • +
      • + map +
      • +
      • + set +
      • +
      • + vector +
      • +
      +
    • +
    • + conversion +
    • +
    • + generation +
    • +
    • + intrinsic +
    • +
    • + io +
    • +
    • + utility +
    • +
    • + view +
        +
      • + filter_view +
      • +
      • + iterator_range +
      • +
      • + joint_view +
      • +
      • + reverse_view +
      • +
      • + single_view +
      • +
      • + transform_view +
      • +
      • + zip_view +
      • +
      +
    • +
    +
  • +
  • + iterator +
  • +
  • + support +
  • +
+

+ + Example +

+

+ If, for example, you want to use list, + depending on the granularity that you desire, you may do so by including one + of +

+
+#include <boost/fusion/sequence.hpp>
+#include <boost/fusion/sequence/container.hpp>
+#include <boost/fusion/sequence/container/list.hpp>
+
+

+ The first includes all sequences. The second includes all of sequence containers. + The third includes only list  + [3] + . +

+
+

+

[3] + Modules may contain smaller components. Header file information for each + component will be provided as part of the component's documentation. +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/preface.html b/doc/html/fusion/preface.html new file mode 100644 index 00000000..9fc7c33d --- /dev/null +++ b/doc/html/fusion/preface.html @@ -0,0 +1,159 @@ + + + +Preface + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Algorithms + Data Structures = Programs. +

+

+ --Niklaus Wirth +

+

+ + Description +

+

+ Fusion is a library for working with hetrogenous collections of data, commonly + referred to as tuples. A set of containers (vector, list, set and map) is provided, + along with views that provide a transformed presentation of their underlying + data. Collectively the containers and views are referred to as sequences, and + Fusion has a suite of algorithms that operate upon the various sequence types, + using an iterator concept that binds everything together. +

+

+ The architecture is modeled after MPL + which in turn is modeled after STL. + It is named "fusion" because the library is a "fusion" + of compile time metaprogramming with runtime programming. +

+

+ + Motivation +

+

+ Tuples are powerful beasts. After having developed two significant projects + (Spirit and Phoenix) + that relied heavily metaprogramming, it became apparent that tuples are a powerful + means to simplify otherwise tricky tasks; especially those that require a combination + of metaprogramming and manipulation of heterogenous data types with values. + While MPL is + an extremely powerful metaprogramming tool, MPL + focuses on type manipulation only. Ultimately, you'll have to map these types + to real values to make them useful in the runtime world where all the real + action takes place. +

+

+ As Spirit and Phoenix + evolved, patterns and idioms related to tuple manipulation emerged. Soon, it + became clear that those patterns and idioms were best assembled in a tuples + algorithms library. David + Abrahams outlined such a scheme in 2002. At that time, it just so happened + that Spirit and Phoenix + had an adhoc collection of tuple manipulation and traversal routines. It was + an instant AHA! moment. +

+

+ + How to use this manual +

+

+ Some icons are used to mark certain topics indicative of their relevance. These + icons precede some text to indicate: +

+
+

+ + Icons +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IconNameMeaning
noteNoteInformation provided + is auxiliary but will give the reader a deeper insight into a specific + topic. May be skipped.
alertAlertInformation provided + is of utmost importance.
cautionCautionA mild warning.
tipTipA potentially useful + and helpful piece of information.
+
+

+ This documentation is automatically generated by Boost QuickBook documentation + tool. QuickBook can be found in the Boost + Tools. +

+

+ + Support +

+

+ Please direct all questions to Spirit's mailing list. You can subscribe to + the Spirit + Mailing List. The mailing list has a searchable archive. A search link + to this archive is provided in Spirit's + home page. You may also read and post messages to the mailing list through + Spirit General + NNTP news portal (thanks to Gmane). + The news group mirrors the mailing list. Here is a link to the archives: http://news.gmane.org/gmane.comp.parsers.spirit.general. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/quick_start.html b/doc/html/fusion/quick_start.html new file mode 100644 index 00000000..fb9c7ab2 --- /dev/null +++ b/doc/html/fusion/quick_start.html @@ -0,0 +1,260 @@ + + + +Quick Start + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ I assume the reader is already familiar with tuples (Boost.Tuple) + and its ancestor std::pair. The tuple is a generalization of std::pair + for multiple heterogeneous elements (triples, quadruples, etc.). The tuple + is more or less a synonym for fusion's vector. +

+

+ For starters, we shall include all of Fusion's _sequence_s + [1] + : +

+
+#include <boost/fusion/sequence.hpp>
+
+

+ Let's begin with a vector  + [2] + : +

+
+vector<int, char, std::string> stuff(1, 'x', "howdy");
+int i = at_c<0>(stuff);
+char ch = at_c<1>(stuff);
+std::string s = at_c<2>(stuff);
+
+

+ Just replace tuple for vector + and get for at_c and this is exactly like + Boost.Tuple. + Actually, either names can be used interchangeably. Yet, the similarity ends + there. You can do a lot more with Fusion vector or tuple. + Let's see some examples. +

+

+ + Print the vector + as XML +

+

+ First, let's include the algorithms: +

+
+#include <boost/fusion/algorithm.hpp>
+
+

+ Now, let's write a function object that prints XML of the form <type>data</type> + for each member in the tuple. +

+
+struct print_xml
+{
+    template <typename T>
+    void operator()(T const& x) const
+    {
+        std::cout 
+            << '<' << typeid(x).name() << '>'
+            << x
+            << "</" << typeid(x).name() << '>'
+            ;
+    }
+};
+
+

+ Now, finally: +

+
+for_each(stuff, print_xml());
+
+

+ That's it! for_each is a fusion algorithm. + It is a generic algorithm similar to STL's. + It iterates over the sequence and calls a user supplied function. In our case, + it calls print_xml's operator() for + each element in stuff. +

+
+ + + + + +
[Caution]Caution

+ The result of typeid(x).name() is platform specific. The code here is + just for exposition. Of course you already know that :-) +

+

+ for_each is generic. With + print_xml, you can use it to + print just about any Fusion Sequence. +

+

+ + Print only pointers +

+

+ Let's get a little cleverer. Say we wish to write a generic + function that takes in an arbitrary sequence and XML prints only those elements + which are pointers. Ah, easy. First, let's include the is_pointer + boost type trait: +

+
+#include <boost/type_traits/is_pointer.hpp>
+
+

+ Then, simply: +

+
+template <typename Sequence>
+void xml_print_pointers(Sequence const& seq)
+{
+    for_each(filter_if<boost::is_pointer<_> >(seq), print_xml());
+}
+
+

+ filter_if is another Fusion + algorithm. It returns a filter_view, a conforming Fusion sequence. + This view reflects only those elements that pass the given predicate. In this + case, the predicate is boost::is_pointer<_>. + This "filtered view" is then passed to the for_each algorithm, which then prints + the "filtered view" as XML. +

+

+ Easy, right? +

+

+ + Associative tuples +

+

+ Ok, moving on... +

+

+ Apart from vector, fusion has a couple + of other sequence types to choose from. Each sequence has its own characteristics. + We have list, set, map, plus a multitude of views that provide various ways to present + the sequences. +

+

+ Fusion's map associate types with elements. + It can be used as a cleverer replacement of the struct. + Example: +

+
+namespace fields
+{
+    struct name;
+    struct age;
+}
+
+typedef map<
+    fusion::pair<fields::name, std::string>
+  , fusion::pair<fields::age, int> > 
+person;
+
+

+ map + is an associative sequence. Its elements are Fusion pairs which differ somewhat + from std::pair. Fusion pairs only contain one member, + with the type of their second template parameter. The first type parameter + of the pair is used as an index to the associated element in the sequence. + For example, given a a_person + of type, person, you can do: +

+
+using namespace fields;
+std::string person_name = at_key<name>(a_person);
+int person_age = at_key<age>(a_person);
+
+

+ Why go through all this trouble, you say? Well, for one, unlike the struct, we are dealing with a generic data structure. + There are a multitude of facilities available at your disposal provided out + of the box with fusion or written by others. With these facilities, introspection + comes for free, for example. We can write one serialization function (well, + two, if you consider loading and saving) that will work for all your fusion + maps. + Example: +

+
+struct saver
+{
+    template <typename Pair>
+    void operator()(Pair const& data) const
+    {
+        some_archive << data.second;
+    }
+};
+
+template <typename Stuff>
+void save(Stuff const& stuff)
+{
+    for_each(stuff, saver());
+}
+
+

+ The save function is generic + and will work for all types of stuff + regardless if it is a person, + a dog or a whole alternate_universe. +

+

+ + Tip of the Iceberg +

+

+ And... we've barely scratched the surface! You can compose and expand the data + structures, remove elements from the structures, find specific data types, + query the elements, filter out types for inspection, transform data structures, + etc. What you've seen is just the tip of the iceberg. +

+
+

+

[1] + There are finer grained header files available if you wish to have more + control over which components to include (see section Orgainization + for details). +

+

[2] + Unless otherwise noted, components are in namespace boost::fusion. + For the sake of simplicity, code in this quick start implies using directives for the fusion components + we will be using. +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/references.html b/doc/html/fusion/references.html new file mode 100644 index 00000000..ef4f7188 --- /dev/null +++ b/doc/html/fusion/references.html @@ -0,0 +1,67 @@ + + + +References + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHome +
+
+ +
    +
  1. +New + Iterator Concepts, David Abrahams, Jeremy Siek, Thomas Witt, 2004-11-01. +
  2. +
  3. +The Boost + Tuple Library, Jaakko Jarvi, 2001. +
  4. +
  5. +Spirit Parser Library, + Joel de Guzman, 2001-2006. +
  6. +
  7. +The Boost MPL Library, + Aleksey Gurtovoy and David Abrahams, 2002-2004. +
  8. +
  9. +Boost Array, + Nicolai Josuttis, 2002-2004. +
  10. +
  11. +Standard Template Library Programmer's + Guide, Hewlett-Packard Company, 1994. +
  12. +
  13. +Boost.Ref, Jaakko + Jarvi, Peter Dimov, Douglas Gregor, Dave Abrahams, 1999-2002. +
  14. +
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHome +
+ + diff --git a/doc/html/fusion/sequences.html b/doc/html/fusion/sequences.html new file mode 100644 index 00000000..005938a7 --- /dev/null +++ b/doc/html/fusion/sequences.html @@ -0,0 +1,65 @@ + + + +Sequences + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Like MPL, the + Sequence is a fundamental concept in Fusion. A Sequence may or may not actually + store or contain data. Containers + are sequences that hold data. Views, + on the other hand, are sequences that do not store any data. Instead, they + are proxies that impart an alternative presentation over another sequence. + All models of Sequence have an associated Iterator + type that can be used to iterate through the Sequence's elements. +

+

+ + Header +

+
+#include <boost/fusion/sequence.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/adapted.html b/doc/html/fusion/sequences/adapted.html new file mode 100644 index 00000000..9de14eed --- /dev/null +++ b/doc/html/fusion/sequences/adapted.html @@ -0,0 +1,70 @@ + + + +Adapted + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion provides a couple of adapters for other sequences such as std::pair, + MPL sequences, + and boost::array. These adapters are written using + Fusion's non-intrusive Extension + mechanism. If you wish to use these sequences with fusion, simply include + the necessary files and they will be regarded as first-class, fully conforming + fusion sequences + [4] + . +

+

+ + Header +

+
+#include <boost/fusion/sequence/adapted.hpp>
+
+
+

+

[4] + Fusion sequences may also be adapted as fully conforming MPL + sequences (see Intrinsics). + That way, we can have 2-way adaptation to and from MPL + and Fusion +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/adapted/boost__array.html b/doc/html/fusion/sequences/adapted/boost__array.html new file mode 100644 index 00000000..2ed12fca --- /dev/null +++ b/doc/html/fusion/sequences/adapted/boost__array.html @@ -0,0 +1,79 @@ + + + +boost::array + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This module provides adapters for boost::array. + Including the module header makes boost::array + a fully conforming Random + Access Sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/adapted/array.hpp>
+
+
+ + Model of +
+ +
+ + Example +
+
+boost::array<int,3> arr = {{1,2,3}};
+
+std::cout << *begin(arr) << std::endl;
+std::cout << *next(begin(arr)) << std::endl;
+std::cout << *advance_c<2>(begin(arr)) << std::endl;
+std::cout << *prior(end(arr)) << std::endl;
+std::cout << at_c<2>(arr) << std::endl;
+
+
+ + See also +
+

+ Boost.Array Library +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/adapted/mpl_sequence.html b/doc/html/fusion/sequences/adapted/mpl_sequence.html new file mode 100644 index 00000000..378644b8 --- /dev/null +++ b/doc/html/fusion/sequences/adapted/mpl_sequence.html @@ -0,0 +1,95 @@ + + + +mpl sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This module provides adapters for MPL + sequences. Including the module header makes all MPL + sequences fully conforming fusion sequences. +

+
+ + Header +
+
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+
+
+ + Model of +
+
+
+ + Example +
+
+mpl::vector_c<int, 123, 456> vec_c;
+fusion::vector2<int, long> v(vec_c);
+std::cout << at_c<0>(v) << std::endl;
+std::cout << at_c<1>(v) << std::endl;
+
+v = mpl::vector_c<int, 456, 789>();
+std::cout << at_c<0>(v) << std::endl;
+std::cout << at_c<1>(v) << std::endl;
+
+
+ + See also +
+

+ MPL +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/adapted/std__pair.html b/doc/html/fusion/sequences/adapted/std__pair.html new file mode 100644 index 00000000..d3a434c0 --- /dev/null +++ b/doc/html/fusion/sequences/adapted/std__pair.html @@ -0,0 +1,77 @@ + + + +std::pair + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This module provides adapters for std::pair. + Including the module header makes std::pair + a fully conforming Random + Access Sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/adapted/std_pair.hpp>
+
+
+ + Model of +
+ +
+ + Example +
+
+std::pair<int, std::string> p(123, "Hola!!!");
+std::cout << at_c<0>(p) << std::endl;
+std::cout << at_c<1>(p) << std::endl;
+std::cout << p << std::endl;
+
+
+ + See also +
+

+ std::pair, + TR1 and std::pair +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/concepts.html b/doc/html/fusion/sequences/concepts.html new file mode 100644 index 00000000..6983f910 --- /dev/null +++ b/doc/html/fusion/sequences/concepts.html @@ -0,0 +1,80 @@ + + + +Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion Sequences are organized into a hierarchy of concepts. +

+

+ + Traversal +

+

+ Fusion's sequence traversal related concepts parallel Fusion's Iterator + Concepts. Forward + Sequence is the most basic concept. Bidirectional + Sequence is a refinement of Forward + Sequence. Random + Access Sequence is a refinement of Bidirectional + Sequence. These concepts pertain to sequence traversal. +

+

+ + Associativity +

+

+ The Associative + Sequence concept is orthogonal to traversal. An Associative Sequence + allows efficient retrieval of elements based on keys. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/concepts/associative_sequence.html b/doc/html/fusion/sequences/concepts/associative_sequence.html new file mode 100644 index 00000000..cc0878cd --- /dev/null +++ b/doc/html/fusion/sequences/concepts/associative_sequence.html @@ -0,0 +1,228 @@ + + + +Associative + Sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ An Associative Sequence allows efficient retrieval of elements based on + keys. Like associative sequences in MPL, + and unlike associative containers in STL, + Fusion associative sequences have no implied ordering relation. Instead, + type identity is used to impose an equivalence relation on keys, and the + order in which sequence elements are traversed during iteration is left + unspecified. In addition, unlike STL, + Associative Sequences have mutable iterators. This is due to the fact that + there is no associated ordering relation and the runtime value of the keys + themselves do not have any effect on the associativity of the sequence. +

+
+

Notation

+
+
s
+
+ An Associative Sequence +
+
S
+
+ An Associative Sequence type +
+
K
+
+ An arbitrary key type +
+
o
+
+ An arbitrary object +
+
e
+
+ A Sequence element +
+
+
+
+ + Valid + Expressions +
+

+ For any Associative Sequence the following expressions must be valid: +

+
+

+ +

+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeType RequirementsRuntime + Complexity
has_key<K>(s)MPL + Boolean Constant. Convertible to bool. Constant
at_key<K>(s)Any + type Constant
at_key<K>(s) = oAny + type +s + is mutable and e = o, + where e is the first + element in the sequence, is a valid expression.Constant
+
+
+ + Result + Type Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::has_key<S, K>::typeAmortized constant + time
result_of::at_key<S, K>::typeAmortized constant + time
result_of::value_at_key<S, K>::typeAmortized constant + time
+
+

+ note result_of::at_key<S, K> + returns the actual type returned by at_key<K>(s). In + most cases, this is a reference. Hence, there is no way to know the exact + element type using result_of::at_key<S, K>.The + element at K may actually + be a reference to begin with. For this purpose, you can use result_of::value_at_key<S, N>. +

+
+ + Expression + Semantics +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + +
ExpressionSemantics
has_key<K>(s)A + boolean Integral Constant c + such that c::value == true if and only if there is one or + more elements with the key k + in s; see has_key.
at_key<K>(s)The + element associated with the key K + in the sequence s; + see at.
+
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/concepts/bidirectional_sequence.html b/doc/html/fusion/sequences/concepts/bidirectional_sequence.html new file mode 100644 index 00000000..8937bd21 --- /dev/null +++ b/doc/html/fusion/sequences/concepts/bidirectional_sequence.html @@ -0,0 +1,236 @@ + + + +Bidirectional + Sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Bidirectional Sequence is a Forward + Sequence whose iterators model Bidirectional + Iterator. +

+
+ + Refinement + of +
+

+ Forward Sequence +

+
+

Notation

+
+
s
+
+ A Forward Sequence +
+
S
+
+ A Forward Sequence type +
+
o
+
+ An arbitrary object +
+
e
+
+ A Sequence element +
+
+
+
+ + Valid + Expressions +
+

+ In addition to the requirements defined in Forward + Sequence, for any Bidirectional Sequence the following must be met: +

+
+

+ +

+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeType RequirementsRuntime + Complexity
begin(s)Bidirectional + Iterator Constant
end(s)Bidirectional + Iterator Constant
back(s)Any + type Constant
back(s) = oAny + type +s + is mutable and e = o, + where e is the first + element in the sequence, is a valid expression.Constant
+
+
+ + Result + Type Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::begin<S>::typeAmortized constant + time
result_of::end<S>::typeAmortized constant + time
result_of::back<S>::typeAmortized constant + time
+
+
+ + Expression + Semantics +
+

+ The semantics of an expression are defined only where they differ from, + or are not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + +
ExpressionSemantics
back(s)The + last element in the sequence; see back.
+
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/concepts/forward_sequence.html b/doc/html/fusion/sequences/concepts/forward_sequence.html new file mode 100644 index 00000000..dd460d28 --- /dev/null +++ b/doc/html/fusion/sequences/concepts/forward_sequence.html @@ -0,0 +1,289 @@ + + + +Forward + Sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Forward Sequence is a Sequence whose elements are arranged in a definite + order. The ordering is guaranteed not to change from iteration to iteration. + The requirement of a definite ordering allows the definition of element-by-element + equality (if the container's element type is Equality Comparable) and of + lexicographical ordering (if the container's element type is LessThan Comparable). +

+
+

Notation

+
+
s
+
+ A Forward Sequence +
+
S
+
+ A Forward Sequence type +
+
o
+
+ An arbitrary object +
+
e
+
+ A Sequence element +
+
+
+
+ + Valid + Expressions +
+

+ For any Forward Sequence the following expressions must be valid: +

+
+

+ +

+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeType RequirementsRuntime + Complexity
begin(s)Forward Iterator Constant
end(s)Forward Iterator Constant
size(s)MPL + Integral Constant. Convertible to int. Constant
empty(s)MPL + Boolean Constant. Convertible to bool. Constant
front(s)Any + type Constant
front(s) = oAny + type +s + is mutable and e = o, + where e is the first + element in the sequence, is a valid expression.Constant
+
+
+ + Result + Type Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::begin<S>::typeAmortized constant + time
result_of::end<S>::typeAmortized constant + time
result_of::size<S>::typeUnspecified
result_of::empty<S>::typeConstant time
result_of::front<S>::typeAmortized constant + time
+
+
+ + Expression + Semantics +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
begin(s)An + iterator to the first element of the sequence; see begin.
end(s)A + past-the-end iterator to the sequence; see end.
size(s)The + size of the sequence; see size.
empty(s)A + boolean Integral Constant c + such that c::value == true if and only if the sequence is + empty; see empty.
front(s)The + first element in the sequence; see front.
+
+
+ + Invariants +
+

+ For any Forward Sequence s the following invariants always hold: +

+
    +
  • +[begin(s), end(s)) is always a valid range. +
  • +
  • + An Algorithm that iterates through + the range [begin(s), end(s)) will pass through every element of + s exactly once. +
  • +
  • +begin(s) + is identical to end(s)) + if and only if s is empty. +
  • +
  • + Two different iterations through s + will access its elements in the same order. +
  • +
+
+ + Models +
+ +
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/concepts/random_access_sequence.html b/doc/html/fusion/sequences/concepts/random_access_sequence.html new file mode 100644 index 00000000..f031f3ac --- /dev/null +++ b/doc/html/fusion/sequences/concepts/random_access_sequence.html @@ -0,0 +1,255 @@ + + + +Random + Access Sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ A Random Access Sequence is a Bidirectional + Sequence whose iterators model Random + Access Iterator. It guarantees constant time access to arbitrary + sequence elements. +

+
+ + Refinement + of +
+

+ Bidirectional + Sequence +

+
+

Notation

+
+
s
+
+ A Random Access Sequence +
+
S
+
+ A Random Access Sequence type +
+
N
+
+ An integral constant +
+
o
+
+ An arbitrary object +
+
e
+
+ A Sequence element +
+
+
+
+ + Valid + Expressions +
+

+ In addition to the requirements defined in Bidirectional + Sequence, for any Random Access Sequence the following must be met: +

+
+

+ +

+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeType RequirementsRuntime + Complexity
begin(s)Random + Access Iterator Constant
end(s)Random + Access Iterator Constant
at<N>(s)Any + type Constant
at<N>(s) = oAny + type +s + is mutable and e = o, + where e is the first + element in the sequence, is a valid expression.Constant
+
+
+ + Result + Type Expressions +
+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + +
ExpressionCompile Time Complexity
result_of::begin<S>::typeAmortized constant + time
result_of::end<S>::typeAmortized constant + time
result_of::at<S, N>::typeAmortized constant + time
result_of::value_at<S, N>::typeAmortized constant + time
+
+

+ note result_of::at<S, N> + returns the actual type returned by at<N>(s). In + most cases, this is a reference. Hence, there is no way to know the exact + element type using result_of::at<S, N>.The + element at N may actually + be a reference to begin with. For this purpose, you can use result_of::value_at<S, N>. +

+
+ + Expression + Semantics +
+

+ The semantics of an expression are defined only where they differ from, + or are not defined in Bidirectional + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + +
ExpressionSemantics
at<N>(s)The + Nth element from the beginning of the sequence; see at.
+
+
+ + Models +
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers.html b/doc/html/fusion/sequences/containers.html new file mode 100644 index 00000000..b5c6ef0a --- /dev/null +++ b/doc/html/fusion/sequences/containers.html @@ -0,0 +1,58 @@ + + + +Containers + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion provides a few predefined sequences out of the box. These containers + actually hold heterogenously typed data; unlike Views. + These containers are more or less counterparts of those in STL. +

+

+ + Header +

+
+#include <boost/fusion/sequence/container.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers/cons.html b/doc/html/fusion/sequences/containers/cons.html new file mode 100644 index 00000000..006b7e29 --- /dev/null +++ b/doc/html/fusion/sequences/containers/cons.html @@ -0,0 +1,236 @@ + + + +cons + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ cons is a simple Forward Sequence. + It is a lisp style recursive list structure where car + is the head and cdr + is the tail: usually another cons structure or nil: the empty list. Fusion's list is built on top of this more + primitive data structure. It is more efficient than vector when the target sequence + is constructed piecemeal (a data at a time). The runtime cost of access + to each element is peculiarly constant (see Recursive + Inlined Functions). +

+
+ + Header +
+
+#include <boost/fusion/sequence/container/list/cons.hpp>
+
+
+ + Synopsis +
+
+template <typename Car, typename Cdr = nil>
+struct cons;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
CarHead + type 
CdrTail + typenil
+
+
+ + Model of +
+ +
+

Notation

+
+
nil
+
+ An empty cons +
+
C
+
+ A cons type +
+
l, + l2
+
+ Instances of cons +
+
car
+
+ An arbitrary data +
+
cdr
+
+ Another cons list +
+
s
+
+ A Forward + Sequence +
+
N
+
+ An Integral Constant +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
nil()Creates + an empty list.
C()Creates + a cons with default constructed elements.
C(car)Creates + a cons with car head + and default constructed tail.
C(car, cdr)Creates + a cons with car head + and cdr tail.
C(s)Copy + constructs a cons from a Forward + Sequence, s.
l = sAssigns to a cons, + l, from a Forward + Sequence, s.
at<N>(l)The + Nth element from the beginning of the sequence; see at.
+
+

+ note at<N>(l) is + provided for convenience and compatibility with the original Boost.Tuple + library, despite cons being + a Forward Sequence + only (at is supposed to + be a Random + Access Sequence requirement). The runtime complexity of at is constant (see Recursive + Inlined Functions). +

+
+ + Example +
+
+cons<int, cons<float> > l(12, cons<float>(5.5f));
+std::cout << at<0>(l) << std::endl;
+std::cout << at<1>(l) << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers/list.html b/doc/html/fusion/sequences/containers/list.html new file mode 100644 index 00000000..83ee0ff4 --- /dev/null +++ b/doc/html/fusion/sequences/containers/list.html @@ -0,0 +1,228 @@ + + + +list + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ list is a Forward + Sequence of heterogenous typed data built on top of cons. It is more efficient than + vector + when the target sequence is constructed piecemeal (a data at a time). The + runtime cost of access to each element is peculiarly constant (see Recursive Inlined Functions). +

+
+ + Header +
+
+#include <boost/fusion/sequence/container/list.hpp>
+#include <boost/fusion/sequence/container/list/list_forward.hpp>
+
+
+ + Synopsis +
+
+template <
+    typename T0 = unspecified
+  , typename T1 = unspecified
+  , typename T2 = unspecified
+    ...
+  , typename TN = unspecified
+>
+struct list;
+
+

+ The variadic class interface accepts 0 + to FUSION_MAX_LIST_SIZE + elements, where FUSION_MAX_LIST_SIZE + is a user definable predefined maximum that defaults to 10. + Example: +

+
+list<int, char, double>
+
+

+ You may define the preprocessor constant FUSION_MAX_LIST_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_LIST_SIZE 20
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
+T0...TN +Element typesunspecified-type
+
+
+ + Model of +
+ +
+

Notation

+
+
L
+
+ A list type +
+
l
+
+ An instance of list +
+
e0...en
+
+ Heterogeneous values +
+
s
+
+ A Forward + Sequence +
+
N
+
+ An Integral Constant +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
L()Creates + a list with default constructed elements.
L(e0, e1,... en)Creates + a list with elements e0...en.
L(s)Copy + constructs a list from a Forward + Sequence, s.
l = sAssigns to a list, + l, from a Forward + Sequence, s.
at<N>(l)The + Nth element from the beginning of the sequence; see at.
+
+

+ note at<n>(l) is + provided for convenience and compatibility with the original Boost.Tuple + library, despite list being + a Forward Sequence + only (at is supposed to be a Random + Access Sequence requirement). The runtime complexity of at is constant (see Recursive + Inlined Functions). +

+
+ + Example +
+
+list<int, float> l(12, 5.5f);
+std::cout << at<0>(l) << std::endl;
+std::cout << at<1>(l) << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers/map.html b/doc/html/fusion/sequences/containers/map.html new file mode 100644 index 00000000..e04c36b2 --- /dev/null +++ b/doc/html/fusion/sequences/containers/map.html @@ -0,0 +1,225 @@ + + + +map + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+map

+
+ + Description +
+

+ map is an Associative + Sequence of heteregenous typed data elements. Each element is a + key/data pair (see fusion::pair) + where the key has no data (type only). Type identity is used to impose + an equivalence relation on keys. A map may contain at most one element + for each key. Membership testing and element key lookup has constant runtime + complexity (see Overloaded + Functions). +

+
+ + Header +
+
+#include <boost/fusion/sequence/container/map.hpp>
+
+
+ + Synopsis +
+
+template <
+    typename T0 = unspecified
+  , typename T1 = unspecified
+  , typename T2 = unspecified
+    ...
+  , typename TN = unspecified
+>
+struct map;
+
+

+ The variadic class interface accepts 0 + to FUSION_MAX_MAP_SIZE + elements, where FUSION_MAX_MAP_SIZE + is a user definable predefined maximum that defaults to 10. + Example: +

+
+map<pair<int, char>, pair<char, char>, pair<double, char> >
+
+

+ You may define the preprocessor constant FUSION_MAX_MAP_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_MAP_SIZE 20
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
+T0...TN +Element typesunspecified-type
+
+
+ + Model of +
+ +
+

Notation

+
+
M
+
+ A map type +
+
m
+
+ An instance of map +
+
e0...en
+
+ Heterogeneous key/value pairs (see fusion::pair) +
+
s
+
+ A Forward + Sequence +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Random + Access Sequence and Associative + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
M()Creates + a map with default constructed elements.
M(e0, e1,... en)Creates + a map with element pairs e0...en.
M(s)Copy + constructs a map from a Forward + Sequence s.
m = sAssigns to a map, + m, from a Forward + Sequence s.
+
+
+ + Example +
+
+typedef map<
+    pair<int, char>
+  , pair<double, std::string> > 
+map_type;
+
+map_type m(
+    make_pair<int>('X')
+  , make_pair<double>("Men"));
+
+std::cout << at<int>(m) << std::endl;
+std::cout << at<double>(m) << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers/set.html b/doc/html/fusion/sequences/containers/set.html new file mode 100644 index 00000000..b3b553ce --- /dev/null +++ b/doc/html/fusion/sequences/containers/set.html @@ -0,0 +1,217 @@ + + + +set + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+set

+
+ + Description +
+

+ set is an Associative + Sequence of heteregenous typed data elements. Type identity is used + to impose an equivalence relation on keys. The element's type is its key. + A set may contain at most one element for each key. Membership testing + and element key lookup has constant runtime complexity (see Overloaded + Functions). +

+
+ + Header +
+
+#include <boost/fusion/sequence/container/set.hpp>
+
+
+ + Synopsis +
+
+template <
+    typename T0 = unspecified
+  , typename T1 = unspecified
+  , typename T2 = unspecified
+    ...
+  , typename TN = unspecified
+>
+struct set;
+
+

+ The variadic class interface accepts 0 + to FUSION_MAX_SET_SIZE + elements, where FUSION_MAX_SET_SIZE + is a user definable predefined maximum that defaults to 10. + Example: +

+
+set<int, char, double>
+
+

+ You may define the preprocessor constant FUSION_MAX_SET_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_SET_SIZE 20
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
+T0...TN +Element typesunspecified-type
+
+
+ + Model of +
+ +
+

Notation

+
+
S
+
+ A set type +
+
s
+
+ An instance of set +
+
e0...en
+
+ Heterogeneous values +
+
fs
+
+ A Forward + Sequence +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Random + Access Sequence and Associative + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
S()Creates + a set with default constructed elements.
S(e0, e1,... en)Creates + a set with elements e0...en.
S(fs)Copy + constructs a set from a Forward + Sequence fs.
s = fsAssigns to a set, + s, from a Forward + Sequence fs.
+
+
+ + Example +
+
+typedef set<int, float> S;
+S s(12, 5.5f);
+std::cout << at_key<int>(s) << std::endl;
+std::cout << at_key<float>(s) << std::endl;
+std::cout << result_of::has_key<S, double>::value << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/containers/vector.html b/doc/html/fusion/sequences/containers/vector.html new file mode 100644 index 00000000..788f029b --- /dev/null +++ b/doc/html/fusion/sequences/containers/vector.html @@ -0,0 +1,247 @@ + + + +vector + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ vector is a Random + Access Sequence of heterogenous typed data structured as a simple + struct where each element + is held as a member variable. vector + is the simplest of the Fusion sequence container, and in many cases the + most efficient. +

+
+ + Header +
+
+#include <boost/fusion/sequence/container/vector.hpp>
+#include <boost/fusion/sequence/container/vector/vector_forward.hpp>
+
+// numbered forms
+#include <boost/fusion/sequence/container/vector/vector10.hpp>
+#include <boost/fusion/sequence/container/vector/vector20.hpp>
+#include <boost/fusion/sequence/container/vector/vector30.hpp>
+#include <boost/fusion/sequence/container/vector/vector40.hpp>
+#include <boost/fusion/sequence/container/vector/vector50.hpp>
+
+
+ + Synopsis +
+

+ Numbered forms +

+
+template <>
+struct vector0;
+
+template <typename T0>
+struct vector1;
+
+template <typename T0, typename T1>
+struct vector2;
+
+template <typename T0, typename T1, typename T2>
+struct vector3;
+
+...
+
+template <typename T0, typename T1, typename T2..., typename TN>
+struct vectorN;
+
+

+ Variadic form +

+
+template <
+    typename T0 = unspecified
+  , typename T1 = unspecified
+  , typename T2 = unspecified
+    ...
+  , typename TN = unspecified
+>
+struct vector;
+
+

+ The numbered form accepts the exact number of elements. Example: +

+
+vector3<int, char, double>
+
+

+ The variadic form accepts 0 + to FUSION_MAX_VECTOR_SIZE + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. + Example: +

+
+vector<int, char, double>
+
+

+ You may define the preprocessor constant FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
+T0...TN +Element typesunspecified
+
+
+ + Model of +
+ +
+

Notation

+
+
v
+
+ Instance of vector +
+
V
+
+ A vector type +
+
e0...en
+
+ Heterogeneous values +
+
s
+
+ A Forward + Sequence +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Random + Access Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
V()Creates + a vector with default constructed elements.
V(e0, e1,... en)Creates + a vector with elements e0...en.
V(s)Copy + constructs a vector from a Forward + Sequence, s.
v = sAssigns to a vector, + v, from a Forward + Sequence, s.
+
+
+ + Example +
+
+vector<int, float> v(12, 5.5f);
+std::cout << at_c<0>(v) << std::endl;
+std::cout << at_c<1>(v) << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion.html b/doc/html/fusion/sequences/conversion.html new file mode 100644 index 00000000..4a468867 --- /dev/null +++ b/doc/html/fusion/sequences/conversion.html @@ -0,0 +1,53 @@ + + + +Conversion + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ All fusion sequences can be converted to one of the Containers + types using one of these conversion functions. +

+

+ + Header +

+
+#include <boost/fusion/sequence/conversion.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/functions.html b/doc/html/fusion/sequences/conversion/functions.html new file mode 100644 index 00000000..ad31a4c8 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/functions.html @@ -0,0 +1,44 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/functions/as_list.html b/doc/html/fusion/sequences/conversion/functions/as_list.html new file mode 100644 index 00000000..092b2d68 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/functions/as_list.html @@ -0,0 +1,114 @@ + + + +as_list + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Convert a fusion sequence to a list. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::as_list<Sequence>::type
+as_list(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::as_list<Sequence const>::type
+as_list(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqAn + instance of SequenceThe sequence to convert.
+
+
+ + Expression + Semantics +
+
+as_list(seq);
+
+

+ Return type: result_of::as_list<Sequence>::type +

+

+ Semantics: Convert a fusion sequence, + seq, to a list. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_list.hpp>
+
+
+ + Example +
+
+as_list(make_vector('x', 123, "hello"))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/functions/as_map.html b/doc/html/fusion/sequences/conversion/functions/as_map.html new file mode 100644 index 00000000..ced5fbfb --- /dev/null +++ b/doc/html/fusion/sequences/conversion/functions/as_map.html @@ -0,0 +1,121 @@ + + + +as_map + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Convert a fusion sequence to a map. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::as_map<Sequence>::type
+as_map(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::as_map<Sequence const>::type
+as_map(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqAn + instance of SequenceThe sequence to convert.
+
+
+ + Expression + Semantics +
+
+as_map(seq);
+
+

+ Return type: result_of::as_map<Sequence>::type +

+

+ Semantics: Convert a fusion sequence, + seq, to a map. +

+

+ Precondition: The elements of the sequence + are assumed to be __fusionpair_s. + There may be no duplicate fusion::pair key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_map.hpp>
+
+
+ + Example +
+
+as_map(make_vector(
+    make_pair<int>('X')
+  , make_pair<double>("Men")))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/functions/as_set.html b/doc/html/fusion/sequences/conversion/functions/as_set.html new file mode 100644 index 00000000..982a76d8 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/functions/as_set.html @@ -0,0 +1,118 @@ + + + +as_set + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Convert a fusion sequence to a set. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::as_set<Sequence>::type
+as_set(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::as_set<Sequence const>::type
+as_set(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqAn + instance of SequenceThe sequence to convert.
+
+
+ + Expression + Semantics +
+
+as_set(seq);
+
+

+ Return type: result_of::as_set<Sequence>::type +

+

+ Semantics: Convert a fusion sequence, + seq, to a set. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_set.hpp>
+
+
+ + Example +
+
+as_set(make_vector('x', 123, "hello"))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/functions/as_vector.html b/doc/html/fusion/sequences/conversion/functions/as_vector.html new file mode 100644 index 00000000..de557ba4 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/functions/as_vector.html @@ -0,0 +1,114 @@ + + + +as_vector + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Convert a fusion sequence to a vector. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::as_vector<Sequence>::type
+as_vector(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::as_vector<Sequence const>::type
+as_vector(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqAn + instance of SequenceThe sequence to convert.
+
+
+ + Expression + Semantics +
+
+as_vector(seq);
+
+

+ Return type: result_of::as_vector<Sequence>::type +

+

+ Semantics: Convert a fusion sequence, + seq, to a vector. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_vector.hpp>
+
+
+ + Example +
+
+as_vector(make_list('x', 123, "hello"))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/metafunctions.html b/doc/html/fusion/sequences/conversion/metafunctions.html new file mode 100644 index 00000000..9241e198 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/metafunctions.html @@ -0,0 +1,44 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/metafunctions/as_list.html b/doc/html/fusion/sequences/conversion/metafunctions/as_list.html new file mode 100644 index 00000000..5b00a350 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/metafunctions/as_list.html @@ -0,0 +1,112 @@ + + + +as_list + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of as_list. +

+
+ + Synopsis +
+
+template <typename Sequence>
+struct as_list;
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + fusion Sequence +The + sequence type to convert.
+
+
+ + Expression + Semantics +
+
+result_of::as_list<Sequence>::type;
+
+

+ Return type: A list with same elements as the + input sequence, Sequence. +

+

+ Semantics: Convert a fusion sequence, + Sequence, to a list. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_list.hpp>
+
+
+ + Example +
+
+result_of::as_list<vector<char, int> >::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/metafunctions/as_map.html b/doc/html/fusion/sequences/conversion/metafunctions/as_map.html new file mode 100644 index 00000000..2de03b86 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/metafunctions/as_map.html @@ -0,0 +1,119 @@ + + + +as_map + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of as_map. +

+
+ + Synopsis +
+
+template <typename Sequence>
+struct as_map;
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + fusion Sequence +The + sequence to convert.
+
+
+ + Expression + Semantics +
+
+result_of::as_map<Sequence>::type;
+
+

+ Return type: A map with same elements as the + input sequence, Sequence. +

+

+ Semantics: Convert a fusion sequence, + Sequence, to a map. +

+

+ Precondition: The elements of the sequence + are assumed to be __fusionpair_s. + There may be no duplicate fusion::pair key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_map.hpp>
+
+
+ + Example +
+
+result_of::as_map<vector<
+    fusion::pair<int, char>
+  , fusion::pair<double, std::string> > >::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/metafunctions/as_set.html b/doc/html/fusion/sequences/conversion/metafunctions/as_set.html new file mode 100644 index 00000000..b5a1a707 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/metafunctions/as_set.html @@ -0,0 +1,116 @@ + + + +as_set + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of as_set. +

+
+ + Synopsis +
+
+template <typename Sequence>
+struct as_set;
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + fusion Sequence +The + sequence to convert.
+
+
+ + Expression + Semantics +
+
+result_of::as_set<Sequence>::type;
+
+

+ Return type: A set with same elements as the + input sequence, Sequence. +

+

+ Semantics: Convert a fusion sequence, + Sequence, to a set. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_set.hpp>
+
+
+ + Example +
+
+result_of::as_set<vector<char, int> >::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/conversion/metafunctions/as_vector.html b/doc/html/fusion/sequences/conversion/metafunctions/as_vector.html new file mode 100644 index 00000000..6d39ef78 --- /dev/null +++ b/doc/html/fusion/sequences/conversion/metafunctions/as_vector.html @@ -0,0 +1,112 @@ + + + +as_vector + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of as_vector. +

+
+ + Synopsis +
+
+template <typename Sequence>
+struct as_vector;
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SequenceA + fusion Sequence +The + sequence to convert.
+
+
+ + Expression + Semantics +
+
+result_of::as_vector<Sequence>::type;
+
+

+ Return type: A vector with same elements as + the input sequence, Sequence. +

+

+ Semantics: Convert a fusion sequence, + Sequence, to a vector. +

+
+ + Header +
+
+#include <boost/fusion/sequence/conversion/as_vector.hpp>
+
+
+ + Example +
+
+result_of::as_vector<list<char, int> >::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation.html b/doc/html/fusion/sequences/generation.html new file mode 100644 index 00000000..0dd9d6fd --- /dev/null +++ b/doc/html/fusion/sequences/generation.html @@ -0,0 +1,52 @@ + + + +Generation + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ These are the functions that you can use to generate various forms of Containers from elemental values. +

+

+ + Header +

+
+#include <boost/fusion/sequence/generation.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions.html b/doc/html/fusion/sequences/generation/functions.html new file mode 100644 index 00000000..202070ae --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions.html @@ -0,0 +1,48 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/list_tie.html b/doc/html/fusion/sequences/generation/functions/list_tie.html new file mode 100644 index 00000000..48f800b4 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/list_tie.html @@ -0,0 +1,126 @@ + + + +list_tie + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Constructs a tie using a list sequence. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+list<T0&, T1&,... TN&>
+list_tie(T0& x0, T1& x1... TN& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_LIST_SIZE + elements, where FUSION_MAX_LIST_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_LIST_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_LIST_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to list_tie +
+
+
+ + Expression + Semantics +
+
+list_tie(x0, x1,... xN);
+
+

+ Return type: list<T0&, T1&,... + TN&> +

+

+ Semantics: Create a list of references from x0, x1,... xN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/list_tie.hpp>
+
+
+ + Example +
+
+int i = 123;
+double d = 123.456;
+list_tie(i, d)
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/make_cons.html b/doc/html/fusion/sequences/generation/functions/make_cons.html new file mode 100644 index 00000000..5163e06a --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/make_cons.html @@ -0,0 +1,137 @@ + + + +make_cons + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Create a cons from car + (head) and optional cdr + (tail). +

+
+ + Synopsis +
+
+template <typename Car>
+typename result_of::make_cons<Car>::type
+make_cons(Car const& car);
+
+template <typename Car, typename Cdr>
+typename result_of::make_cons<Car, Cdr>::type
+make_cons(Car const& car, Cdr const& cdr);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
carInstance + of Car +The + list's head
cdrInstance + of Cdr +The + list's tail (optional)
+
+
+ + Expression + Semantics +
+
+make_cons(car, cdr);
+
+

+ Return type: result_of::make_cons<Car, Cdr>::type or result_of::make_cons<Car>::type +

+

+ Semantics: Create a cons from car + (head) and optional cdr + (tail). +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_cons.hpp>
+
+
+ + Example +
+
+make_cons('x', make_cons(123))
+
+
+ + See + also +
+

+ boost::ref +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/make_list.html b/doc/html/fusion/sequences/generation/functions/make_list.html new file mode 100644 index 00000000..8804b024 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/make_list.html @@ -0,0 +1,131 @@ + + + +make_list + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Create a list from one or more values. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+typename result_of::make_list<T0, T1,... TN>::type
+make_list(T0 const& x0, T1 const& x1... TN const& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_LIST_SIZE + elements, where FUSION_MAX_LIST_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_LIST_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_LIST_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to make_list +
+
+
+ + Expression + Semantics +
+
+make_list(x0, x1,... xN);
+
+

+ Return type: result_of::make_list<T0, T1,... TN>::type +

+

+ Semantics: Create a list from x0, x1,... xN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_list.hpp>
+
+
+ + Example +
+
+make_list(123, "hello", 12.5)
+
+
+ + See + also +
+

+ boost::ref +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/make_map.html b/doc/html/fusion/sequences/generation/functions/make_map.html new file mode 100644 index 00000000..a475dbb6 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/make_map.html @@ -0,0 +1,159 @@ + + + +make_map + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Create a map from one or more key/data + pairs. +

+
+ + Synopsis +
+
+template <
+    typename K0, typename K1,... typename KN
+  , typename T0, typename T1,... typename TN>
+typename result_of::make_map<K0, K0,... KN, T0, T1,... TN>::type
+make_map(T0 const& x0, T1 const& x1... TN const& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + [10] + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
K0, K1,... KNThe key typesKeys + associated with x0, x1,... xN +
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to make_map +
+
+
+ + Expression + Semantics +
+
+make_map<K0, K1,... KN>(x0, x1,... xN);
+
+

+ Return type: result_of::make_map<K0, K0,... KN, T0, T1,... TN>::type +

+

+ Semantics: Create a map from K0, K1,... KN + keys and x0, x1,... xN data. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_map.hpp>
+
+
+ + Example +
+
+make_map(
+    make_pair<int>('X')
+  , make_pair<double>("Men"))
+
+
+ + See + also +
+

+ boost::ref, + fusion::pair +

+
+

+

[10] + map is implemented + in terms of the vector. That is why we reuse FUSION_MAX_VECTOR_SIZE +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/make_set.html b/doc/html/fusion/sequences/generation/functions/make_set.html new file mode 100644 index 00000000..7298b243 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/make_set.html @@ -0,0 +1,143 @@ + + + +make_set + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Create a set from one or more values. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+typename result_of::make_set<T0, T1,... TN>::type
+make_set(T0 const& x0, T1 const& x1... TN const& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + [9] + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to make_set +
+
+
+ + Expression + Semantics +
+
+make_set(x0, x1,... xN);
+
+

+ Return type: result_of::make_set<T0, T1,... TN>::type +

+

+ Semantics: Create a set from x0, x1,... xN. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_set.hpp>
+
+
+ + Example +
+
+make_set(123, "hello", 12.5)
+
+
+ + See + also +
+

+ boost::ref +

+
+

+

[9] + set is implemented + in terms of the vector. That is why we reuse FUSION_MAX_VECTOR_SIZE +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/make_vector.html b/doc/html/fusion/sequences/generation/functions/make_vector.html new file mode 100644 index 00000000..2deac697 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/make_vector.html @@ -0,0 +1,131 @@ + + + +make_vector + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Create a vector from one or more values. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+typename result_of::make_vector<T0, T1,... TN>::type
+make_vector(T0 const& x0, T1 const& x1... TN const& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to make_vector +
+
+
+ + Expression + Semantics +
+
+make_vector(x0, x1,... xN);
+
+

+ Return type: result_of::make_vector<T0, T1,... TN>::type +

+

+ Semantics: Create a vector from x0, x1,... xN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_vector.hpp>
+
+
+ + Example +
+
+make_vector(123, "hello", 12.5)
+
+
+ + See + also +
+

+ boost::ref +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/tiers.html b/doc/html/fusion/sequences/generation/functions/tiers.html new file mode 100644 index 00000000..9a4defb4 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/tiers.html @@ -0,0 +1,99 @@ + + + +Tiers + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Tiers are sequences, where all elements are non-const reference types. + They are constructed with a call to a couple of tie + function templates. The succeeding sections document the various tier + flavors. +

+ +

+ Example: +

+
+int i; char c; double d; 
+  ...
+vector_tie(i, c, a);
+
+

+ The vector_tie function creates + a vector + of type vector<int&, char&, double&>. + The same result could be achieved with the call make_vector(ref(i), ref(c), ref(a)) + [11] + . +

+

+ A tie can be used to 'unpack' another tuple into + variables. E.g.: +

+
+int i; char c; double d; 
+vector_tie(i, c, d) = make_vector(1,'a', 5.5);
+std::cout << i << " " <<  c << " " << d;
+
+

+ This code prints 1 a 5.5 to the standard output stream. A sequence unpacking + operation like this is found for example in ML and Python. It is convenient + when calling functions which return sequences. +

+
+ + Ignore +
+

+ There is also an object called ignore which allows + you to ignore an element assigned by a sequence. The idea is that a function + may return a sequence, only part of which you are interested in. For + example: +

+
+char c;
+vector_tie(ignore, c) = make_vector(1, 'a');
+
+
+

+

[11] + see Boost.Ref + for details about ref +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/functions/vector_tie.html b/doc/html/fusion/sequences/generation/functions/vector_tie.html new file mode 100644 index 00000000..ccd43dd8 --- /dev/null +++ b/doc/html/fusion/sequences/generation/functions/vector_tie.html @@ -0,0 +1,126 @@ + + + +vector_tie + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Constructs a tie using a vector sequence. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+vector<T0&, T1&,... TN&>
+vector_tie(T0& x0, T1& x1... TN& xN);
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
x0, x1,... xNInstances of + T0, T1,... TN +The arguments + to vector_tie +
+
+
+ + Expression + Semantics +
+
+vector_tie(x0, x1,... xN);
+
+

+ Return type: vector<T0&, T1&,... + TN&> +

+

+ Semantics: Create a vector of references from x0, x1,... xN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/vector_tie.hpp>
+
+
+ + Example +
+
+int i = 123;
+double d = 123.456;
+vector_tie(i, d)
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions.html b/doc/html/fusion/sequences/generation/metafunctions.html new file mode 100644 index 00000000..3143a7b0 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions.html @@ -0,0 +1,47 @@ + + + +MetaFunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/list_tie.html b/doc/html/fusion/sequences/generation/metafunctions/list_tie.html new file mode 100644 index 00000000..dc11981f --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/list_tie.html @@ -0,0 +1,121 @@ + + + +list_tie + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of list_tie. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+struct list_tie;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_LIST_SIZE + elements, where FUSION_MAX_LIST_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_LIST_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_LIST_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
T0, T1,... TNAny typeThe + arguments to list_tie +
+
+
+ + Expression + Semantics +
+
+result_of::list_tie<T0, T1,... TN>::type;
+
+

+ Return type: list<T0&, T1&,... + TN&> +

+

+ Semantics: Create a list of references from T0, T1,... TN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/list_tie.hpp>
+
+
+ + Example +
+
+result_of::list_tie<int, double>::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/make_cons.html b/doc/html/fusion/sequences/generation/metafunctions/make_cons.html new file mode 100644 index 00000000..5e3c7339 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/make_cons.html @@ -0,0 +1,122 @@ + + + +make_cons + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of make_cons. +

+
+ + Synopsis +
+
+template <typename Car, typename Cdr = nil>
+struct make_cons;
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
CarAny + typeThe list's head type
CdrA + cons +The + list's tail type (optional)
+
+
+ + Expression + Semantics +
+
+result_of::make_cons<Car, Cdr>::type
+
+

+ Return type: A cons with head element, Car, of type converted following the + rules for element + conversion, and tail, Cdr. +

+

+ Semantics: Create a cons from Car + (head) and optional Cdr + (tail). +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_cons.hpp>
+
+
+ + Example +
+
+result_of::make_cons<char, result_of::make_cons<int>::type>::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/make_list.html b/doc/html/fusion/sequences/generation/metafunctions/make_list.html new file mode 100644 index 00000000..acc31cef --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/make_list.html @@ -0,0 +1,122 @@ + + + +make_list + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of make_list. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+struct make_list;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_LIST_SIZE + elements, where FUSION_MAX_LIST_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_LIST_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_LIST_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
T0, T1,... TNAny typeTemplate + arguments to make_list +
+
+
+ + Expression + Semantics +
+
+result_of::make_list<T0, T1,... TN>::type
+
+

+ Return type: A list with elements of types + converted following the rules for element + conversion. +

+

+ Semantics: Create a list from T0, T1,... TN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_list.hpp>
+
+
+ + Example +
+
+result_of::make_list<int, const char(&)[7], double>::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/make_map.html b/doc/html/fusion/sequences/generation/metafunctions/make_map.html new file mode 100644 index 00000000..a9983836 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/make_map.html @@ -0,0 +1,153 @@ + + + +make_map + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of make_map. +

+
+ + Synopsis +
+
+template <
+    typename K0, typename K1,... typename KN
+  , typename T0, typename T1,... typename TN>
+struct make_map;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + [13] + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
K0, K1,... KNAny typeKeys + associated with T0, T1,... TN +
T0, T1,... TNAny typeData + associated with keys K0, K1,... KN +
+
+
+ + Expression + Semantics +
+
+resulf_of::make_map<K0, K1,... KN, T0, T1,... TN>::type;
+
+

+ Return type: result_of::make_map<K0, K0,... KN, T0, T1,... TN>::type +

+

+ Semantics: A map with fusion::pair elements where the second_type is converted following + the rules for element + conversion. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_map.hpp>
+
+
+ + Example +
+
+result_of::make_map<int, double, char, double>::type
+
+
+ + See + also +
+

+ fusion::pair +

+
+

+

[13] + map is implemented + in terms of the vector. That is why we reuse FUSION_MAX_VECTOR_SIZE +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/make_set.html b/doc/html/fusion/sequences/generation/metafunctions/make_set.html new file mode 100644 index 00000000..317ea0c3 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/make_set.html @@ -0,0 +1,134 @@ + + + +make_set + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of make_set. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+struct make_set;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + [12] + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
T0, T1,... TNAny typeThe + arguments to make_set +
+
+
+ + Expression + Semantics +
+
+result_of::make_set<T0, T1,... TN>::type
+
+

+ Return type: A set with elements of types converted + following the rules for element + conversion. +

+

+ Semantics: Create a set from T0, T1,... TN. +

+

+ Precondition: There may be no duplicate + key types. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_set.hpp>
+
+
+ + Example +
+
+result_of::make_set<int, char, double>::type
+
+
+

+

[12] + set is implemented + in terms of the vector. That is why we reuse FUSION_MAX_VECTOR_SIZE +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/make_vector.html b/doc/html/fusion/sequences/generation/metafunctions/make_vector.html new file mode 100644 index 00000000..572041c0 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/make_vector.html @@ -0,0 +1,122 @@ + + + +make_vector + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of make_vector. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+struct make_vector;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
T0, T1,... TNAny typeTemplate + arguments to make_vector +
+
+
+ + Expression + Semantics +
+
+result_of::make_vector<T0, T1,... TN>::type
+
+

+ Return type: A vector with elements of types + converted following the rules for element + conversion. +

+

+ Semantics: Create a vector from T0, T1,... TN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/make_list.hpp>
+
+
+ + Example +
+
+result_of::make_vector<int, const char(&)[7], double>::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/generation/metafunctions/vector_tie.html b/doc/html/fusion/sequences/generation/metafunctions/vector_tie.html new file mode 100644 index 00000000..7a81eb16 --- /dev/null +++ b/doc/html/fusion/sequences/generation/metafunctions/vector_tie.html @@ -0,0 +1,121 @@ + + + +vector_tie + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of vector_tie. +

+
+ + Synopsis +
+
+template <typename T0, typename T1,... typename TN>
+struct vector_tie;
+
+

+ The variadic function accepts 0 + to FUSION_MAX_VECTOR_SIZE + elements, where FUSION_MAX_VECTOR_SIZE + is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant + FUSION_MAX_VECTOR_SIZE + before including any Fusion header to change the default. Example: +

+
+#define FUSION_MAX_VECTOR_SIZE 20
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
T0, T1,... TNAny typeThe + arguments to vector_tie +
+
+
+ + Expression + Semantics +
+
+result_of::vector_tie<T0, T1,... TN>::type;
+
+

+ Return type: vector<T0&, T1&,... + TN&> +

+

+ Semantics: Create a vector of references from T0, T1,... TN. +

+
+ + Header +
+
+#include <boost/fusion/sequence/generation/vector_tie.hpp>
+
+
+ + Example +
+
+result_of::vector_tie<int, double>::type
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics.html b/doc/html/fusion/sequences/intrinsics.html new file mode 100644 index 00000000..d3896d63 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics.html @@ -0,0 +1,66 @@ + + + +Intrinsics + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Intrinsics form the essential interface of Fusion _sequence_s. + STL + counterparts of these functions are usually implemented as member functions. + Intrinsic functions, unlike Algorithms, + are not generic across the full Sequence + repertoire. They need to be implemented for each Fusion Sequence + [5] + . +

+

+ + Header +

+
+#include <boost/fusion/sequence/intrinsic.hpp>
+
+
+

+

[5] + In practice, many of intrinsic functions have default implementations + that will work in majority of cases +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions.html b/doc/html/fusion/sequences/intrinsics/functions.html new file mode 100644 index 00000000..37df07d8 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions.html @@ -0,0 +1,50 @@ + + + +Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/at.html b/doc/html/fusion/sequences/intrinsics/functions/at.html new file mode 100644 index 00000000..aeeb6343 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/at.html @@ -0,0 +1,139 @@ + + + +at + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+at
+
+ + Description +
+

+ Returns the N-th element from the beginning of the sequence. +

+
+ + Synopsis +
+
+template <typename N, typename Sequence>
+typename result_of::at<Sequence, N>::type
+at(Sequence& seq);
+
+template <typename N, typename Sequence>
+typename result_of::at<Sequence const, N>::type
+at(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Random + Access Sequence +The sequence we wish to investigate.
NAn + MPL + integral constantAn index from the beginning of + the sequence.
+
+
+ + Expression + Semantics +
+
+at<N>(seq);
+
+

+ Return type: Returns a reference to + the N-th element from the beginning of the sequence seq + if seq is mutable and + e = o, where e + is the N-th element from the beginning of the sequence, is a valid expression. + Else, returns a type convertable to the N-th element from the beginning + of the sequence. +

+

+ Precondition: 0 <= N::value < size(s) +

+

+ Semantics: Equivalent to +

+
+deref(advance<N>(begin(s)))
+
+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(at<mpl::int_<1> >(v) == 2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/at_c.html b/doc/html/fusion/sequences/intrinsics/functions/at_c.html new file mode 100644 index 00000000..0ffc2615 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/at_c.html @@ -0,0 +1,138 @@ + + + +at_c + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the N-th element from the beginning of the sequence. +

+
+ + Synopsis +
+
+template <int N, typename Sequence>
+typename result_of::at_c<Sequence, N>::type
+at_c(Sequence& seq);
+
+template <int N, typename Sequence>
+typename result_of::at_c<Sequence const, N>::type
+at_c(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Random + Access Sequence +The sequence we wish to investigate.
NAn + integral constantAn index from the beginning of + the sequence.
+
+
+ + Expression + Semantics +
+
+at_c<N>(seq);
+
+

+ Return type: Returns a reference to + the N-th element from the beginning of the sequence seq + if seq is mutable and + e = o, where e + is the N-th element from the beginning of the sequence, is a valid expression. + Else, returns a type convertable to the N-th element from the beginning + of the sequence. +

+

+ Precondition: 0 <= N < size(s) +

+

+ Semantics: Equivalent to +

+
+deref(advance<N>(begin(s)))
+
+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at_c.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(at_c<1>(v) == 2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/at_key.html b/doc/html/fusion/sequences/intrinsics/functions/at_key.html new file mode 100644 index 00000000..f448522c --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/at_key.html @@ -0,0 +1,134 @@ + + + +at_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the element associated with a Key from the sequence. +

+
+ + Synopsis +
+
+template <typename Key, typename Sequence>
+typename result_of::at_key<Sequence, Key>::type
+at_key(Sequence& seq);
+
+template <typename Key, typename Sequence>
+typename result_of::at_key<Sequence const, Key>::type
+at_key(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Associative + Sequence +The sequence we wish to investigate.
KeyAny + typeThe queried key.
+
+
+ + Expression + Semantics +
+
+at_key<Key>(seq);
+
+

+ Return type: Returns a reference to + the element associated with Key from the sequence seq + if seq is mutable and + e = o, where e + is the element associated with Key, is a valid expression. Else, returns + a type convertable to the element associated with Key. +

+

+ Precondition: has_key<Key>(seq) == true +

+

+ Semantics: Returns the element associated + with Key. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+
+
+ + Example +
+
+set<int, char, bool> s(1, 'x', true);
+assert(at_key<char>(s) == 'x');
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/back.html b/doc/html/fusion/sequences/intrinsics/functions/back.html new file mode 100644 index 00000000..3f4a5021 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/back.html @@ -0,0 +1,126 @@ + + + +back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the last element in the sequence. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::back<Sequence>::type
+back(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::back<Sequence const>::type
+back(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Bidirectional + Sequence +The sequence we wish to investigate.
+
+
+ + Expression + Semantics +
+
+back(seq);
+
+

+ Return type: Returns a reference to + the last element in the sequence seq + if seq is mutable and + e = o, where e + is the last element in the sequence, is a valid expression. Else, returns + a type convertable to the last element in the sequence. +

+

+ Precondition: empty(seq) == false +

+

+ Semantics: Returns the last element + in the sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/back.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(back(v) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/begin.html b/doc/html/fusion/sequences/intrinsics/functions/begin.html new file mode 100644 index 00000000..755c9c85 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/begin.html @@ -0,0 +1,134 @@ + + + +begin + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns an iterator pointing to the first element in the sequence. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::begin<Sequence>::type
+begin(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::begin<Sequence const>::type
+begin(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Forward + Sequence +The sequence we wish to get an iterator + from.
+
+
+ + Expression + Semantics +
+
+begin(seq);
+
+

+ Return type: Forward + Iterator if seq + is a Forward + Sequence else, Bidirectional + Iterator if seq + is a Bidirectional + Sequence else, Random + Access Iterator if seq + is a Random + Access Sequence. +

+

+ Semantics: Returns an iterator pointing + to the first element in the sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/begin.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(deref(begin(v)) == 1);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/empty.html b/doc/html/fusion/sequences/intrinsics/functions/empty.html new file mode 100644 index 00000000..84e4b147 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/empty.html @@ -0,0 +1,116 @@ + + + +empty + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a type convertible to bool + that evaluates to true if + the sequence is empty, else, evaluates to false. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::empty<Sequence>::type
+empty(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Forward + Sequence +The sequence we wish to investigate.
+
+
+ + Expression + Semantics +
+
+empty(seq);
+
+

+ Return type: Convertible to bool. +

+

+ Semantics: Evaluates to true if the sequence is empty, else, evaluates + to false. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/empty.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(empty(v) == false);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/end.html b/doc/html/fusion/sequences/intrinsics/functions/end.html new file mode 100644 index 00000000..41d27f73 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/end.html @@ -0,0 +1,134 @@ + + + +end + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+end
+
+ + Description +
+

+ Returns an iterator pointing to one element past the end of the sequence. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::end<Sequence>::type
+end(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::end<Sequence const>::type
+end(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Forward + Sequence +The sequence we wish to get an iterator + from.
+
+
+ + Expression + Semantics +
+
+end(seq);
+
+

+ Return type: Forward + Iterator if seq + is a Forward + Sequence else, Bidirectional + Iterator if seq + is a Bidirectional + Sequence else, Random + Access Iterator if seq + is a Random + Access Sequence. +

+

+ Semantics: Returns an iterator pointing + to one element past the end of the sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(deref(prior(end(v))) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/front.html b/doc/html/fusion/sequences/intrinsics/functions/front.html new file mode 100644 index 00000000..fad5941d --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/front.html @@ -0,0 +1,126 @@ + + + +front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the first element in the sequence. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::front<Sequence>::type
+front(Sequence& seq);
+
+template <typename Sequence>
+typename result_of::front<Sequence const>::type
+front(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Forward + Sequence +The sequence we wish to investigate.
+
+
+ + Expression + Semantics +
+
+front(seq);
+
+

+ Return type: Returns a reference to + the first element in the sequence seq + if seq is mutable and + e = o, where e + is the first element in the sequence, is a valid expression. Else, returns + a type convertable to the first element in the sequence. +

+

+ Precondition: empty(seq) == false +

+

+ Semantics: Returns the first element + in the sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/front.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(front(v) == 1);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/has_key.html b/doc/html/fusion/sequences/intrinsics/functions/has_key.html new file mode 100644 index 00000000..aabd7a1a --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/has_key.html @@ -0,0 +1,125 @@ + + + +has_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a type convertible to bool + that evaluates to true if + the sequence contains an element associated with a Key, else, evaluates + to false. +

+
+ + Synopsis +
+
+template <typename Key, typename Sequence>
+typename result_of::has_key<Sequence, Key>::type
+has_key(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Associative + Sequence +The sequence we wish to investigate.
KeyAny + typeThe queried key.
+
+
+ + Expression + Semantics +
+
+has_key<Key>(seq);
+
+

+ Return type: Convertible to bool. +

+

+ Semantics: Evaluates to true if the sequence contains an element + associated with Key, else, evaluates to false. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/has_key.hpp>
+
+
+ + Example +
+
+set<int, char, bool> s(1, 'x', true);
+assert(has_key<char>(s) == true);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/functions/size.html b/doc/html/fusion/sequences/intrinsics/functions/size.html new file mode 100644 index 00000000..a01e55ae --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/functions/size.html @@ -0,0 +1,115 @@ + + + +size + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns a type convertible to int + that evaluates the number of elements in the sequence. +

+
+ + Synopsis +
+
+template <typename Sequence>
+typename result_of::size<Sequence>::type
+size(Sequence const& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
seqModel + of Forward + Sequence +The sequence we wish to investigate.
+
+
+ + Expression + Semantics +
+
+size(seq);
+
+

+ Return type: Convertible to int. +

+

+ Semantics: Returns the number of elements + in the sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+
+
+ + Example +
+
+vector<int, int, int> v(1, 2, 3);
+assert(size(v) == 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions.html b/doc/html/fusion/sequences/intrinsics/metafunctions.html new file mode 100644 index 00000000..eafb7ed6 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions.html @@ -0,0 +1,53 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+ + + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/at.html b/doc/html/fusion/sequences/intrinsics/metafunctions/at.html new file mode 100644 index 00000000..9b703c5b --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/at.html @@ -0,0 +1,134 @@ + + + +at + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+at
+
+ + Description +
+

+ Returns the result type of at + [6] + . +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    typename N>
+struct at
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
NAn + MPL Integral ConstantIndex of element
+
+
+ + Expression + Semantics +
+
+result_of::at<Seq, N>::type
+
+

+ Return type: Any type. +

+

+ Semantics: Returns the result type of + using at to access the Nth element of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+
+
+ + Example +
+
+typedef vector<int,float,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::at<vec, boost::mpl::int_<1> >::type, float&>));
+
+
+

+

[6] + result_of::at reflects the actual return + type of the function at. _sequence_s + typically return references to its elements via the at function. If you want + to get the actual element type, use result_of::value_at +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/at_c.html b/doc/html/fusion/sequences/intrinsics/metafunctions/at_c.html new file mode 100644 index 00000000..5f0d7fa8 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/at_c.html @@ -0,0 +1,134 @@ + + + +at_c + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of at_c + [7] + . +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    int M>
+struct at_c
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
MPositive + integer indexIndex of element
+
+
+ + Expression + Semantics +
+
+result_of::at_c<Seq, M>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the result type of + using at_c to access the Mth element of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+
+
+ + Example +
+
+typedef vector<int,float,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::at_c<vec, 1>::type, float&>));
+
+
+

+

[7] + result_of::at_c reflects the actual + return type of the function at_c. _sequence_s + typically return references to its elements via the at_c function. If you want + to get the actual element type, use result_of::value_at_c +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/at_key.html b/doc/html/fusion/sequences/intrinsics/metafunctions/at_key.html new file mode 100644 index 00000000..39c8141f --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/at_key.html @@ -0,0 +1,136 @@ + + + +at_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of at_key + [8] + . +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    typename Key>
+struct at_key
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
KeyAny + typeKey type
+
+
+ + Expression + Semantics +
+
+result_of::at_key<Seq, Key>::type
+
+

+ Return type: Any type. +

+

+ Semantics: Returns the result of using + at_key to access the element + with key type Key in + Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+
+
+ + Example +
+
+typedef map<pair<int, char>, pair<char, char>, pair<double, char> > mymap;
+BOOST_MPL_ASSERT((boost::is_same<result_of::at_key<mymap, int>::type, char&>));
+
+
+

+

[8] + result_of::at_key reflects the actual + return type of the function at_key. _sequence_s + typically return references to its elements via the at_key function. If you + want to get the actual element type, use result_of::value_at_key +

+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/back.html b/doc/html/fusion/sequences/intrinsics/metafunctions/back.html new file mode 100644 index 00000000..f76bb7c4 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/back.html @@ -0,0 +1,113 @@ + + + +back + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of back. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct back
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::back<Seq>::type
+
+

+ Return type: Any type +

+

+ Semantics: The type returned by dereferencing + an iterator to the last element in the sequence. Equivalent to result_of::deref<result_of::prior<result_of::end<Seq>::type>::type>::type. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/back.hpp>
+
+
+ + Example +
+
+typedef vector<int,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::back<vec>::type, char&>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/begin.html b/doc/html/fusion/sequences/intrinsics/metafunctions/begin.html new file mode 100644 index 00000000..b5b70462 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/begin.html @@ -0,0 +1,115 @@ + + + +begin + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of begin. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct begin
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::begin<Seq>::type
+
+

+ Return type: An iterator modelling the + same traversal concept as Seq. +

+

+ Semantics: Returns the type of an iterator + to the first element of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/begin.hpp>
+
+
+ + Example +
+
+typedef vector<int> vec;
+typedef result_of::begin<vec>::type it;
+BOOST_MPL_ASSERT((boost::is_same<result_of::deref<it>::type, int&>))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/empty.html b/doc/html/fusion/sequences/intrinsics/metafunctions/empty.html new file mode 100644 index 00000000..4f9b6938 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/empty.html @@ -0,0 +1,117 @@ + + + +empty + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of empty. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct empty
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::empty<Seq>::type
+
+

+ Return type: An MPL Integral Constant +

+

+ Semantics: Returns mpl::true_ + if Seq has zero elements, + mpl::false_ otherwise. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/empty.hpp>
+
+
+ + Example +
+
+typedef vector<> empty_vec;
+typedef vector<int,float,char> vec;
+
+BOOST_MPL_ASSERT((result_of::empty<empty_vec>));
+BOOST_MPL_ASSERT_NOT((result_of::empty<vec>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/end.html b/doc/html/fusion/sequences/intrinsics/metafunctions/end.html new file mode 100644 index 00000000..a08bad3d --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/end.html @@ -0,0 +1,115 @@ + + + +end + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+end
+
+ + Description +
+

+ Returns the result type of end. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct end
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::end<Seq>::type
+
+

+ Return type: A model of the same traversal + concept as Seq. +

+

+ Semantics: Returns the type of an iterator + one past the end of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+
+
+ + Example +
+
+typedef vector<int> vec;
+typedef result_of::prior<result_of::end<vec>::type>::type first;
+BOOST_MPL_ASSERT((result_of::equal_to<first, result_of::begin<vec>::type>))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/front.html b/doc/html/fusion/sequences/intrinsics/metafunctions/front.html new file mode 100644 index 00000000..33a20b05 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/front.html @@ -0,0 +1,114 @@ + + + +front + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of front. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct front
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::front<Seq>::type
+
+

+ Return type: Any type +

+

+ Semantics: The type returned by dereferencing + an iterator to the first element in Seq. + Equivalent to result_of::deref<result_of::begin<Seq>::type>::type. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/front.hpp>
+
+
+ + Example +
+
+typedef vector<int,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::front<vec>::type, int&>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/has_key.html b/doc/html/fusion/sequences/intrinsics/metafunctions/has_key.html new file mode 100644 index 00000000..fef877f4 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/has_key.html @@ -0,0 +1,126 @@ + + + +has_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of has_key. +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    typename Key>
+struct has_key
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
KeyAny + typeKey type
+
+
+ + Expression + Semantics +
+
+result_of::has_key<Seq, Key>::type
+
+

+ Return type: An MPL Integral Constant. +

+

+ Semantics: Returns mpl::true_ + if Seq contains an element + with key type Key, returns + mpl::false_ otherwise. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/has_key.hpp>
+
+
+ + Example +
+
+typedef map<pair<int, char>, pair<char, char>, pair<double, char> > mymap;
+BOOST_MPL_ASSERT((result_of::has_key<mymap, int>));
+BOOST_MPL_ASSERT_NOT((result_of::has_key<mymap, void*>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/size.html b/doc/html/fusion/sequences/intrinsics/metafunctions/size.html new file mode 100644 index 00000000..b21ab597 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/size.html @@ -0,0 +1,114 @@ + + + +size + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the result type of size. +

+
+ + Synopsis +
+
+template<typename Seq>
+struct size
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
+
+
+ + Expression + Semantics +
+
+result_of::size<Seq>::type
+
+

+ Return type: An MPL Integral Constant. +

+

+ Semantics: Returns the number of elements + in Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+
+
+ + Example +
+
+typedef vector<int,float,char> vec;
+typedef result_of::size<vec>::type size_mpl_integral_constant;
+BOOST_MPL_ASSERT_RELATION(size_mpl_integral_constant::value, ==, 3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/value_at.html b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at.html new file mode 100644 index 00000000..fdb2d75a --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at.html @@ -0,0 +1,123 @@ + + + +value_at + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the actual type at a given index from the Sequence. +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    typename N>
+struct value_at
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
NAn + MPL Integral ConstantIndex of element
+
+
+ + Expression + Semantics +
+
+result_of::value_at<Seq, N>::type
+
+

+ Return type: Any type. +

+

+ Semantics: Returns the actual type at + the Nth element of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
+
+
+ + Example +
+
+typedef vector<int,float,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_at<vec, boost::mpl::int_<1> >::type, float>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_c.html b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_c.html new file mode 100644 index 00000000..85d9fda2 --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_c.html @@ -0,0 +1,123 @@ + + + +value_at_c + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the actual type at a given index from the Sequence. +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    int M>
+struct value_at_c
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
MPositive + integer indexIndex of element
+
+
+ + Expression + Semantics +
+
+result_of::value_at_c<Seq, M>::type
+
+

+ Return type: Any type +

+

+ Semantics: Returns the actual type at + the Mth element of Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
+
+
+ + Example +
+
+typedef vector<int,float,char> vec;
+BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_c<vec, 1>::type, float>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_key.html b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_key.html new file mode 100644 index 00000000..31de542b --- /dev/null +++ b/doc/html/fusion/sequences/intrinsics/metafunctions/value_at_key.html @@ -0,0 +1,124 @@ + + + +value_at_key + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Returns the actual element type associated with a Key from the Sequence. +

+
+ + Synopsis +
+
+template<
+    typename Seq,
+    typename Key>
+struct value_at_key
+{
+    typedef unspecified type;
+};
+
+
+

+ + Parameters +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
SeqA + model of Forward + Sequence +Argument sequence
KeyAny + typeKey type
+
+
+ + Expression + Semantics +
+
+result_of::value_at_key<Seq, Key>::type
+
+

+ Return type: Any type. +

+

+ Semantics: Returns the actual element + type associated with key type Key + in Seq. +

+
+ + Header +
+
+#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
+
+
+ + Example +
+
+typedef map<pair<int, char>, pair<char, char>, pair<double, char> > mymap;
+BOOST_MPL_ASSERT((boost::is_same<result_of::at_key<mymap, int>::type, char>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators.html b/doc/html/fusion/sequences/operators.html new file mode 100644 index 00000000..ea5ab678 --- /dev/null +++ b/doc/html/fusion/sequences/operators.html @@ -0,0 +1,47 @@ + + + +Operators + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ These operators, like the Algorithms, + work generically on all Fusion sequences. All conforming Fusion sequences + automatically get these operators for free. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison.html b/doc/html/fusion/sequences/operators/comparison.html new file mode 100644 index 00000000..95ae379c --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison.html @@ -0,0 +1,67 @@ + + + +Comparison + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The Comparison operators: ==, + !=, <, + <=, >= + and >= work generically + on all Fusion sequences. Comparison operators are "short- circuited": + elementary comparisons start from the first elements and are performed + only until the result is clear. +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/equal.html b/doc/html/fusion/sequences/operators/comparison/equal.html new file mode 100644 index 00000000..2310081d --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/equal.html @@ -0,0 +1,136 @@ + + + +equal + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ Compare two sequences for equality. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator==(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a == b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a == b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, e1 == e2 returns true. For any 2 zero length + _sequence_s, e and f, e == f returns + true. +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+
+
+ + Example +
+
+vector<int, char> v1(5, 'a');
+vector<int, char> v2(5, 'a');
+assert(v1 == v2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/greater_than.html b/doc/html/fusion/sequences/operators/comparison/greater_than.html new file mode 100644 index 00000000..f10608af --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/greater_than.html @@ -0,0 +1,130 @@ + + + +greater + than + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Lexicographically compare two sequences. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator>(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a > b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a < b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: Returns b < a. +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/less_equal.hpp>
+
+
+ + Example +
+
+vector<int, float> v1(4, 3.3f);
+vector<short, float> v2(5, 3.3f);
+vector<long, double> v3(5, 4.4);
+assert(v2 > v1);
+assert(v3 > v2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/greater_than_equal.html b/doc/html/fusion/sequences/operators/comparison/greater_than_equal.html new file mode 100644 index 00000000..c559a726 --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/greater_than_equal.html @@ -0,0 +1,129 @@ + + + +greater + than equal + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Lexicographically compare two sequences. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator>=(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a >= b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a < b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: Returns !(a < b). +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/greater_equal.hpp>
+
+
+ + Example +
+
+vector<int, float> v1(4, 3.3f);
+vector<short, float> v2(5, 3.3f);
+vector<long, double> v3(5, 4.4);
+assert(v2 >= v1);
+assert(v3 >= v2);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/less_than.html b/doc/html/fusion/sequences/operators/comparison/less_than.html new file mode 100644 index 00000000..674810b8 --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/less_than.html @@ -0,0 +1,132 @@ + + + +less + than + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Lexicographically compare two sequences. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator<(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a < b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a < b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: Returns the lexicographical + comparison of between a + and b. +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/less.hpp>
+
+
+ + Example +
+
+vector<int, float> v1(4, 3.3f);
+vector<short, float> v2(5, 3.3f);
+vector<long, double> v3(5, 4.4);
+assert(v1 < v2);
+assert(v2 < v3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/less_than_equal.html b/doc/html/fusion/sequences/operators/comparison/less_than_equal.html new file mode 100644 index 00000000..4a26df94 --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/less_than_equal.html @@ -0,0 +1,130 @@ + + + +less + than equal + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Lexicographically compare two sequences. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator<=(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a <= b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a < b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: Returns !(b < a). +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/less_equal.hpp>
+
+
+ + Example +
+
+vector<int, float> v1(4, 3.3f);
+vector<short, float> v2(5, 3.3f);
+vector<long, double> v3(5, 4.4);
+assert(v1 <= v2);
+assert(v2 <= v3);
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/comparison/not_equal.html b/doc/html/fusion/sequences/operators/comparison/not_equal.html new file mode 100644 index 00000000..3852e2fa --- /dev/null +++ b/doc/html/fusion/sequences/operators/comparison/not_equal.html @@ -0,0 +1,132 @@ + + + +not + equal + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Compare two sequences for inequality. +

+
+ + Synopsis +
+
+template <typename Seq1, typename Seq2>
+bool
+operator!=(Seq1 const& a, Seq2 const& b);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
a, bInstances of + Sequence + +_sequence_s to compare
+
+
+ + Expression + Semantics +
+
+a != b
+
+

+ Return type: bool +

+

+ Requirements: +

+

+ For each element, e1, + in sequence a, and for + each element, e2, in + sequence b, a == b is a valid expression returning a + type that is convertible to bool. +

+

+ An attempt to compare two Sequences of different lengths results in a + compile time error. +

+

+ Semantics: +

+

+ Returns !(a == b). +

+
+ + Header +
+
+#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
+
+
+ + Example +
+
+vector<int, char> v3(5, 'b');
+vector<int, char> t4(2, 'a');
+assert(v1 != v3);
+assert(v1 != t4);
+assert(!(v1 != v2));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/i_o.html b/doc/html/fusion/sequences/operators/i_o.html new file mode 100644 index 00000000..1c2eb76a --- /dev/null +++ b/doc/html/fusion/sequences/operators/i_o.html @@ -0,0 +1,134 @@ + + + +I/O + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+I/O

+
+
in
+
out
+
+

+ The I/O operators: << + and >> work generically + on all Fusion sequences. The global operator<< has been overloaded for generic + output streams such that _sequence_s + are output by recursively calling operator<< for each element. Analogously, + the global operator>> + has been overloaded to extract _sequence_s + from generic input streams by recursively calling operator>> for each element. +

+

+ The default delimiter between the elements is space, and the Sequence + is enclosed in parenthesis. For Example: +

+
+vector<float, int, std::string> a(1.0f, 2, std::string("Howdy folks!");
+cout << a; 
+
+

+ outputs the vector as: (1.0 2 Howdy folks!) +

+

+ The library defines three manipulators for changing the default behavior: +

+
+

Manipulators

+
+
tuple_open(arg)
+
+ Defines the character that is output before the first element. +
+
tuple_close(arg)
+
+ Defines the character that is output after the last element. +
+
tuple_delimiter(arg)
+
+ Defines the delimiter character between elements. +
+
+
+

+ The argument to tuple_open, + tuple_close and tuple_delimiter may be a char, wchar_t, + a C-string, or a wide C-string. +

+

+ Example: +

+
+std::cout << tuple_open('[') << tuple_close(']') << tuple_delimiter(", ") << a;
+
+

+ outputs the same vector, a + as: [1.0, 2, Howdy folks!] +

+

+ The same manipulators work with operator>> and istream + as well. Suppose the std::cin + stream contains the following data: +

+
+(1 2 3) [4:5]
+
+

+ The code: +

+
+vector<int, int, int> i;
+vector<int, int> j;
+
+std::cin >> i;
+std::cin >> set_open('[') >> set_close(']') >> set_delimiter(':');
+std::cin >> j;
+
+

+ reads the data into the _vector_s + i and j. +

+

+ Note that extracting _sequence_s + with std::string or C-style string elements does + not generally work, since the streamed Sequence + representation may not be unambiguously parseable. +

+
+ + Header +
+
+#include <boost/fusion/sequence/io.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/i_o/in.html b/doc/html/fusion/sequences/operators/i_o/in.html new file mode 100644 index 00000000..002fd6d2 --- /dev/null +++ b/doc/html/fusion/sequences/operators/i_o/in.html @@ -0,0 +1,120 @@ + + + +in + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+in
+
+ + Description +
+

+ Read a Sequence from an input + stream. +

+
+ + Synopsis +
+
+template <typename IStream, typename Sequence>
+IStream&
+operator>>(IStream& is, Sequence& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
isAn input stream.Stream to + extract information from.
seqA Sequence.The + sequence to read.
+
+
+ + Expression + Semantics +
+
+is >> seq
+
+

+ Return type: IStream& +

+

+ Semantics: For each element, e, in sequence, seq, + call is >> e. +

+
+ + Header +
+
+#include <boost/fusion/sequence/io/in.hpp>
+
+
+ + Example +
+
+vector<int, std::string, char> v;
+std::cin >> v;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/operators/i_o/out.html b/doc/html/fusion/sequences/operators/i_o/out.html new file mode 100644 index 00000000..b0c27168 --- /dev/null +++ b/doc/html/fusion/sequences/operators/i_o/out.html @@ -0,0 +1,119 @@ + + + +out + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+out
+
+ + Description +
+

+ Write a Sequence to an output + stream. +

+
+ + Synopsis +
+
+template <typename OStream, typename Sequence>
+OStream&
+operator<<(OStream& os, Sequence& seq);
+
+
+ + Parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterRequirementDescription
osAn output stream.Stream + to write information to.
seqA Sequence.The + sequence to write.
+
+
+ + Expression + Semantics +
+
+os << seq
+
+

+ Return type: OStream& +

+

+ Semantics: For each element, e, in sequence, seq, + call os << e. +

+
+ + Header +
+
+#include <boost/fusion/sequence/io/out.hpp>
+
+
+ + Example +
+
+std::cout << make_vector(123, "Hello", 'x') << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views.html b/doc/html/fusion/sequences/views.html new file mode 100644 index 00000000..e820f532 --- /dev/null +++ b/doc/html/fusion/sequences/views.html @@ -0,0 +1,63 @@ + + + +Views + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Views are sequences that do not actually contain data, but instead impart + an alternative presentation over the data from one or more underlying sequences. + Views are proxies. They provide an efficient yet purely functional way to + work on potentially expensive sequence operations. Views are inherently lazy. + Their elements are only computed on demand only when the elements of the + underlying sequence(s) are actually accessed. Views' lazy nature make them + very cheap to copy and be passed around by value. +

+

+ + Header +

+
+#include <boost/fusion/sequence/view.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/filter_view.html b/doc/html/fusion/sequences/views/filter_view.html new file mode 100644 index 00000000..522a59ef --- /dev/null +++ b/doc/html/fusion/sequences/views/filter_view.html @@ -0,0 +1,192 @@ + + + +filter_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ filter_view is a view into + a subset of its underlying sequence's elements satisfying a given predicate + (an MPL metafunction). + The filter_view presents + only those elements for which its predicate evaluates to mpl::true_. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/filter_view.hpp>
+
+
+ + Synopsis +
+
+template <typename Sequence, typename Pred>
+struct filter_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
SequenceA + Forward + Sequence + 
PredUnary + Metafunction returning an mpl::bool_ + 
+
+
+ + Model of +
+ +
+

Notation

+
+
F
+
+ A filter_view type +
+
f, + f2
+
+ Instances of filter_view +
+
s
+
+ A Forward + Sequence +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
F(s)Creates + a filter_view given + a sequence, s.
F(f)Copy + constructs a filter_view + from another filter_view, + f.
f = f2Assigns to a + filter_view, f, from another filter_view, + f2.
+
+
+ + Example +
+
+using boost::mpl::_;
+using boost::mpl::not_;
+using boost::is_class;
+
+typedef vector<std::string, char, long, bool, double> vector_type;
+
+vector_type v("a-string", '@', 987654, true, 6.6);
+filter_view<vector_type const, not_<is_class<_> > > view(v);
+std::cout << view << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/iterator_range.html b/doc/html/fusion/sequences/views/iterator_range.html new file mode 100644 index 00000000..504c2891 --- /dev/null +++ b/doc/html/fusion/sequences/views/iterator_range.html @@ -0,0 +1,197 @@ + + + +iterator_range + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ iterator_range presents + a sub-range of its underlying sequence delimited by a pair of iterators. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/iterator_range.hpp>
+
+
+ + Synopsis +
+
+template <typename First, typename Last>
+struct iterator_range;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
FirstA + fusion Iterator + 
LastA + fusion Iterator + 
+
+
+ + Model of +
+ +
+

Notation

+
+
IR
+
+ An iterator_range type +
+
f
+
+ An instance of First +
+
l
+
+ An instance of Last +
+
ir, + ir2
+
+ Instances of iterator_range +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
IR(f, l)Creates + an iterator_range + given iterators, f + and l.
IR(ir)Copy + constructs an iterator_range + from another iterator_range, + ir.
ir = ir2Assigns to a + iterator_range, + ir, from another + iterator_range, + ir2.
+
+
+ + Example +
+
+char const* s = "Ruby";
+typedef vector<int, char, double, char const*> vector_type;
+vector_type vec(1, 'x', 3.3, s);
+
+typedef result_of::begin<vector_type>::type A;
+typedef result_of::end<vector_type>::type B;
+typedef result_of::next<A>::type C;
+typedef result_of::prior<B>::type D;
+
+C c(vec);
+D d(vec);
+
+iterator_range<C, D> range(c, d);
+std::cout << range << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/joint_view.html b/doc/html/fusion/sequences/views/joint_view.html new file mode 100644 index 00000000..7cc7416a --- /dev/null +++ b/doc/html/fusion/sequences/views/joint_view.html @@ -0,0 +1,191 @@ + + + +joint_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ joint_view presents a view + which is a concatenation of two sequences. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/joint_view.hpp>
+
+
+ + Synopsis +
+
+template <typename Sequence1, typename Sequence2>
+struct joint_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
Sequence1A + Forward + Sequence + 
Sequence2A + Forward + Sequence + 
+
+
+ + Model of +
+ +
+

Notation

+
+
JV
+
+ A joint_view type +
+
s1
+
+ An instance of Sequence1 +
+
s2
+
+ An instance of Sequence2 +
+
jv, + jv2
+
+ Instances of joint_view +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
JV(s1, s2)Creates + a joint_view given + sequences, s1 and + s2.
JV(jv)Copy + constructs a joint_view + from another joint_view, + jv.
jv = jv2Assigns to a + joint_view, jv, from another joint_view, jv2.
+
+
+ + Example +
+
+vector<int, char> v1(3, 'x');
+vector<std::string, int> v2("hello", 123);
+joint_view<
+    vector<int, char>
+  , vector<std::string, int>
+> view(v1, v2);
+std::cout << view << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/reverse_view.html b/doc/html/fusion/sequences/views/reverse_view.html new file mode 100644 index 00000000..e2d7fbf3 --- /dev/null +++ b/doc/html/fusion/sequences/views/reverse_view.html @@ -0,0 +1,171 @@ + + + +reverse_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ reverse_view presents a + reversed view of underlying sequence. The first element will be its last + and the last element will be its first. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/reverse_view.hpp>
+
+
+ + Synopsis +
+
+template <typename Sequence>
+struct reverse_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
SequenceA + Bidirectional + Sequence + 
+
+
+ + Model of +
+ +
+

Notation

+
+
RV
+
+ A reverse_view type +
+
s
+
+ An instance of Sequence +
+
rv, + rv2
+
+ Instances of reverse_view +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Bidirectional + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
RV(s)Creates + a unary reverse_view + given sequence, s.
RV(rv)Copy + constructs a reverse_view + from another reverse_view, + rv.
rv = rv2Assigns to a + reverse_view, rv, from another reverse_view, rv2.
+
+
+ + Example +
+
+typedef vector<int, short, double> vector_type;
+vector_type vec(2, 5, 3.3);
+
+reverse_view<vector_type> reverse(vec);
+std::cout << reverse << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/single_view.html b/doc/html/fusion/sequences/views/single_view.html new file mode 100644 index 00000000..1edc1b25 --- /dev/null +++ b/doc/html/fusion/sequences/views/single_view.html @@ -0,0 +1,164 @@ + + + +single_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ single_view is a view into + a value as a single element sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/single_view.hpp>
+
+
+ + Synopsis +
+
+template <typename T>
+struct single_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
TAny + type 
+
+
+ + Model of +
+ +
+

Notation

+
+
S
+
+ A single_view type +
+
s, + s2
+
+ Instances of single_view +
+
x
+
+ An instance of T +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
S(x)Creates + a single_view from + x.
S(s)Copy + constructs a single_view + from another single_view, + s.
s = s2Assigns to a + single_view, s, from another single_view, + s2.
+
+
+ + Example +
+
+single_view<int> view(3);
+std::cout << view << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/transform_view.html b/doc/html/fusion/sequences/views/transform_view.html new file mode 100644 index 00000000..139601d3 --- /dev/null +++ b/doc/html/fusion/sequences/views/transform_view.html @@ -0,0 +1,280 @@ + + + +transform_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ transform_view presents + a transformed view of its underlying sequence given a unary Polymorphic + Function Object. The transform_view + inherits the traversal characteristics (see Sequence + Traversal Concept) of its underlying sequence. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/transform_view.hpp>
+
+
+ + Synopsis +
+

+ Unary Version +

+
+template <typename Sequence, typename F>
+struct transform_view;
+
+

+ Binary Version +

+
+template <typename Sequence1, typename Sequence2, typename F>
+struct transform_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
SequenceA + Forward + Sequence + 
Sequence1A + Forward + Sequence + 
Sequence2A + Forward + Sequence + 
FA + Polymorphic + Function Object + 
+
+
+ + Model of +
+
+
+

Notation

+
+
TV
+
+ A transform_view type +
+
BTV
+
+ A binary transform_view + type +
+
UTV
+
+ A unary transform_view + type +
+
f
+
+ An instance of F +
+
s
+
+ An instance of Sequence +
+
s1
+
+ An instance of Sequence1 +
+
s2
+
+ An instance of Sequence2 +
+
tv, + tv2
+
+ Instances of transform_view +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence, Bidirectional + Sequence or Random + Access Sequence depending on the traversal characteristics (see + Sequence Traversal + Concept) of its underlying sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
UTV(s, f)Creates + a unary transform_view + given sequence, s + and unary Polymorphic + Function Object, f.
BTV(s1, s2, f)Creates + a binary transform_view + given sequences, s1 + and s2 and unary + Polymorphic + Function Object, f.
TV(tv)Copy + constructs a transform_view + from another transform_view, + tv.
tv = tv2Assigns to a + transform_view, + tv, from another + transform_view, + tv2.
+
+
+ + Example +
+
+struct square
+{
+    template <typename T>
+    struct result
+    {
+        typedef T type;
+    };
+
+    template <typename T>
+    T operator()(T x) const
+    {
+        return x * x;
+    }
+};
+
+typedef vector<int, short, double> vector_type;
+vector_type vec(2, 5, 3.3);
+
+transform_view<vector_type, square> transform(vec, square());
+std::cout << transform << std::endl;
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/sequences/views/zip_view.html b/doc/html/fusion/sequences/views/zip_view.html new file mode 100644 index 00000000..30e29b55 --- /dev/null +++ b/doc/html/fusion/sequences/views/zip_view.html @@ -0,0 +1,176 @@ + + + +zip_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ zip_view presents a view + which iterates over a collection of _sequence_s + in parallel. A zip_view + is constructed from a Sequence + of references to the component _sequence_s. +

+
+ + Header +
+
+#include <boost/fusion/sequence/view/zip_view.hpp>
+
+
+ + Synopsis +
+
+template <typename Sequences>
+struct zip_view;
+
+
+ + Template + parameters +
+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterDescriptionDefault
SequencesA + Forward + Sequence of references to other Fusion _sequence_s 
+
+
+ + Model of +
+ +
+

Notation

+
+
ZV
+
+ A joint_view type +
+
s
+
+ An instance of Sequences +
+
zv1, + zv2
+
+ Instances of ZV +
+
+
+
+ + Expression + Semantics +
+

+ Semantics of an expression is defined only where it differs from, or is + not defined in Forward + Sequence. +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
ZV(s)Creates + a zip_view given + a sequence of references to the component _sequence_s.
ZV(zv1)Copy + constructs a zip_view + from another zip_view, + zv.
zv1 = zv2Assigns + to a zip_view, zv, from another zip_view, zv2.
+
+
+ + Example +
+
+typedef vector<int,int> vec1;
+typedef vector<char,char> vec2;
+vec1 v1(1,2);
+vec2 v2('a','b');
+typedef vector<vec1&, vec2&> sequences;
+std::cout << zip_view<sequences>(sequences(v1, v2)) << std::endl; // ((1 a) (2 b))
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support.html b/doc/html/fusion/support.html new file mode 100644 index 00000000..532ba0f4 --- /dev/null +++ b/doc/html/fusion/support.html @@ -0,0 +1,48 @@ + + + +Support + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ A couple of classes and metafunctions provide basic support for Fusion. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support/category_of.html b/doc/html/fusion/support/category_of.html new file mode 100644 index 00000000..52e3b9e1 --- /dev/null +++ b/doc/html/fusion/support/category_of.html @@ -0,0 +1,164 @@ + + + +category_of + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ A metafunction that establishes the conceptual classification of a particular + Sequence or Iterator + (see Iterator Concepts and + Sequence Concepts). +

+

+ + Synopsis +

+
+namespace traits
+{
+    template <typename T>
+    struct category_of 
+    {
+        typedef unspecified type;
+    };
+}
+
+

+ + Parameters +

+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
TAny + typeThe type to query.
+
+

+ + Expression + Semantics +

+
+typedef traits::category_of<T>::type category;
+
+

+ Return type: +

+

+ For Iterators, the return type is derived from one of: +

+
+struct incrementable_traversal_tag {};
+
+struct single_pass_traversal_tag
+    : incrementable_traversal_tag {};
+
+struct forward_traversal_tag
+    : single_pass_traversal_tag {};
+
+struct bidirectional_traversal_tag
+    : forward_traversal_tag {};
+
+struct random_access_traversal_tag
+    : bidirectional_traversal_tag {};
+
+

+ For Sequences, the return type is derived from one of: +

+
+struct incrementable_sequence_tag {};
+
+struct single_pass_sequence_tag
+    : incrementable_sequence_tag {};
+
+struct forward_sequence_tag
+    : single_pass_sequence_tag {};
+
+struct bidirectional_sequence_tag
+    : forward_sequence_tag {};
+
+struct random_access_sequence_tag
+    : bidirectional_sequence_tag {};
+
+

+ And optionally from: +

+
+struct associative_sequence_tag {};
+
+

+ Semantics: Establishes the conceptual classification + of a particular Sequence or Iterator. +

+

+ + Header +

+
+#include <boost/fusion/support/category_of.hpp>
+
+

+ + Example +

+
+using boost::is_base_of;
+typedef traits::category_of<list<> >::type list_category;
+typedef traits::category_of<vector<> >::type vector_category;
+BOOST_MPL_ASSERT(( is_base_of<forward_sequence_tag, list_category> ));
+BOOST_MPL_ASSERT(( is_base_of<random_access_sequence_tag, vector_category> ));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support/is_sequence.html b/doc/html/fusion/support/is_sequence.html new file mode 100644 index 00000000..c937264d --- /dev/null +++ b/doc/html/fusion/support/is_sequence.html @@ -0,0 +1,126 @@ + + + +is_sequence + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ Metafunction that evaluates to mpl::true_ + if a certain type T is a + conforming Fusion Sequence, mpl::false_ + otherwise. This may be specialized to accomodate clients which provide Fusion + conforming sequences. +

+

+ + Synopsis +

+
+namespace traits
+{
+    template <typename T>
+    struct is_sequence 
+    {
+        typedef unspecified type;
+    };
+}
+
+

+ + Parameters +

+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
TAny + typeThe type to query.
+
+

+ + Expression + Semantics +

+
+typedef traits::is_sequence<T>::type c;
+
+

+ Return type: An MPL Boolean Constant. +

+

+ Semantics: Metafunction that evaluates to + mpl::true_ if a certain type T + is a conforming Fusion sequence, mpl::false_ + otherwise. +

+

+ + Header +

+
+#include <boost/fusion/support/is_sequence.hpp>
+
+

+ + Example +

+
+BOOST_MPL_ASSERT_NOT(( traits::is_sequence< std::vector<int> > ));
+BOOST_MPL_ASSERT_NOT(( is_sequence< int > ));
+BOOST_MPL_ASSERT(( traits::is_sequence<list<> > ));
+BOOST_MPL_ASSERT(( traits::is_sequence<list<int> > ));
+BOOST_MPL_ASSERT(( traits::is_sequence<vector<> > ));
+BOOST_MPL_ASSERT(( traits::is_sequence<vector<int> > ));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support/is_view.html b/doc/html/fusion/support/is_view.html new file mode 100644 index 00000000..fedd2a6a --- /dev/null +++ b/doc/html/fusion/support/is_view.html @@ -0,0 +1,130 @@ + + + +is_view + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ Metafunction that evaluates to mpl::true_ + if a certain type T is a + conforming Fusion View, mpl::false_ + otherwise. A view is a specialized sequence that does not actually contain + data. Views hold sequences which may be other views. In general, views are + held by other views by value, while non-views are held by other views by + reference. is_view may be + specialized to accomodate clients providing Fusion conforming views. +

+

+ + Synopsis +

+
+namespace traits
+{
+    template <typename T>
+    struct is_view 
+    {
+        typedef unspecified type;
+    };
+}
+
+

+ + Parameters +

+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
TAny + typeThe type to query.
+
+

+ + Expression Semantics +

+
+typedef traits::is_view<T>::type c;
+
+

+ Return type: An MPL Boolean Constant. +

+

+ Semantics: Metafunction that evaluates to + mpl::true_ if a certain type T + is a conforming Fusion view, mpl::false_ + otherwise. +

+

+ + Header +

+
+#include <boost/fusion/support/is_view.hpp>
+
+

+ + Example +

+
+BOOST_MPL_ASSERT_NOT(( traits::is_view<std::vector<int> > ));
+BOOST_MPL_ASSERT_NOT(( traits::is_view<int> ));
+
+using boost::mpl::_
+using boost::is_pointer;
+typedef vector<int*, char, long*, bool, double> vector_type;
+typedef filter_view<vector_type, is_pointer<_> > filter_view_type;
+BOOST_MPL_ASSERT(( traits::is_view<filter_view_type> ));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support/pair.html b/doc/html/fusion/support/pair.html new file mode 100644 index 00000000..4535ab65 --- /dev/null +++ b/doc/html/fusion/support/pair.html @@ -0,0 +1,212 @@ + + + +pair + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ Fusion pair type is a half + runtime pair. A half runtime pair is similar to a std::pair, + but, unlike std::pair, + the first type does not have data. It is used as elements in _map_s, + for example. +

+

+ + Synopsis +

+
+template <typename First, typename Second>
+struct pair;
+
+

+ + Template parameters +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + +
ParameterDescription
FirstThe first type. This is purely a type. No + data is held.
SecondThe second type. This contains data.
+
+
+

Notation

+
+
P
+
+ Fusion pair type +
+
p, + p2
+
+ Fusion pairs +
+
F, + S
+
+ Arbitrary types +
+
s
+
+ Value of type S +
+
o
+
+ Output stream +
+
i
+
+ Input stream +
+
+
+

+ + Expression Semantics +

+
+

+ +

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionSemantics
P::first_typeThe type + of the first template parameter, F.
P::second_typeThe type + of the second template parameter, S.
P()Default + construction.
P(s)Construct + a pair given value for the second type, s.
P(p2)Copy + constructs a pair from another pair, p2.
p = p2Assigns a pair, + p1, from another pair, p2.
make_pair<F>(s)Make a pair given the first + type, F, and a value + for the second type, s. + The second type assumes the type of s +
o << pOutput p to output stream, o.
i >> pInput p from input stream, i.
p == p2Tests two pairs + for equality.
p != p2Tests two pairs + for inequality.
+
+

+ + Header +

+
+#include <boost/fusion/support/pair.hpp>
+
+

+ + Example +

+
+pair<int, char> p('X');
+std::cout << p << std::endl;
+std::cout << make_pair<int>('X') << std::endl;
+assert((p == make_pair<int>('X')));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/support/tag_of.html b/doc/html/fusion/support/tag_of.html new file mode 100644 index 00000000..012840fb --- /dev/null +++ b/doc/html/fusion/support/tag_of.html @@ -0,0 +1,130 @@ + + + +tag_of + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ All conforming Fusion sequences and iterators have an associated tag type. + The purpose of the tag is to enable tag + dispatching from Intrinsic + functions to implementations appropriate for the type. The default implementation + of tag_of returns T::ftag + for a given type T, if such + a member typedef exists. +

+

+ This metafunction may be specialized to accomodate clients providing Fusion + conforming sequences. +

+

+ + Synopsis +

+
+namespace traits
+{
+    template<typename Sequence>
+    struct tag_of 
+    {
+        typedef unspecified type;
+    };
+}
+
+

+ namespace traits { template<typename Sequence> struct tag_of { typedef + unspecified type; }; } [heading Parameters] +

+
+

+ +

+ +++++ + + + + + + + + + + +
ParameterRequirementDescription
TAny + typeThe type to query.
+
+

+ + Expression Semantics +

+
+typedef traits::tag_of<T>::type tag;
+
+

+ Return type: Any type. +

+

+ Semantics: Returns the tag type associated + with T. +

+

+ + Header +

+
+#include <boost/fusion/support/tag_of.hpp>
+
+

+ + Example +

+
+typedef traits::is_sequence<list<> tag1;
+typedef traits::is_sequence<list<int> > tag2;
+typedef traits::is_sequence<vector<> > tag3;
+typedef traits::is_sequence<vector<int> > tag4;
+
+BOOST_MPL_ASSERT((boost::is_same<tag1, tag2>));
+BOOST_MPL_ASSERT((boost::is_same<tag3, tag4>));
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples.html b/doc/html/fusion/tuples.html new file mode 100644 index 00000000..f3881d14 --- /dev/null +++ b/doc/html/fusion/tuples.html @@ -0,0 +1,53 @@ + + + +Tuples + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The TR1 technical report describes extensions to the C++ standard library. + Many of these extensions will be considered for the next iteration of the C++ + standard. TR1 describes a tuple type, and support for treating std::pair + as a type of tuple. +

+

+ Fusion provides full support for the TR1 + Tuple interface, and the extended uses of std::pair described + in the TR1 document. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple.html b/doc/html/fusion/tuples/class_template_tuple.html new file mode 100644 index 00000000..26b5015d --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple.html @@ -0,0 +1,79 @@ + + + +Class template tuple + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ Fusion's implementation of the TR1 + Tuple is also a fusion Forward + Sequence. As such the fusion tuple type provides a lot of functionality + beyond that required by TR1. +

+

+ Currently tuple is basically a synonym for vector, although this may be changed + in future releases of fusion. +

+

+ + Synopsis +

+
+template<
+    typename T1 = unspecified,
+    typename T2 = unspecified,
+    ...
+    typename TN = unspecified>
+class tuple;
+
+

+ + Header +

+
+#include <boost/fusion/tuple.hpp>
+
+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple/construction.html b/doc/html/fusion/tuples/class_template_tuple/construction.html new file mode 100644 index 00000000..abb7f4bd --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple/construction.html @@ -0,0 +1,128 @@ + + + +Construction + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ The TR1 + Tuple type provides a default constructor, a constructor that takes + initializers for all of its elements, a copy constructor, and a converting + copy constructor. The details of the various constructors are described + in this section. +

+
+ + Specification +
+
+

Notation

+
+
T1 + ... TN, + U1 ... + UN
+
+ Tuple element types +
+
P1 + ... PN
+
+ Parameter types +
+
Ti, + Ui
+
+ The type of the ith element + of a tuple +
+
Pi
+
+ The type of the ith parameter +
+
+
+
+tuple();
+
+

+ Requirements: Each Ti + is default constructable. +

+

+ Semantics: Default initializes each element + of the tuple. +

+
+tuple(P1,P2,...,PN);
+
+

+ Requirements: Each Pi + is Ti if Ti is a reference type, const Ti& otherwise. +

+

+ Semantics: Copy initializes each element + with the corresponding parameter. +

+
+tuple(const tuple& t);
+
+

+ Requirements: Each Ti + should be copy constructable. +

+

+ Semantics: Copy constructs each element + of *this + with the corresponding element of t. +

+
+template<typename U1, typename U2, ..., typename UN>
+tuple(const tuple<U1, U2, ..., UN>& t);
+
+

+ Requirements: Each Ti + shall be constructible from the corresponding Ui. +

+

+ Semantics: Constructs each element of + *this + with the corresponding element of t. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple/element_access.html b/doc/html/fusion/tuples/class_template_tuple/element_access.html new file mode 100644 index 00000000..3dc0ab26 --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple/element_access.html @@ -0,0 +1,90 @@ + + + +Element + access + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ The TR1 + Tuple provides the get + function to provide access to it's elements by zero based numeric index. +

+
+ + Specification +
+
+template<int I, T>
+RJ get(T& t);
+
+

+ Requires: 0 < I <= N. + The program is ill formed if I + is out of bounds. T is + any fusion sequence type, including tuple. +

+

+ Return type: RJ + is equivalent to result_of::at_c<I,T>::type. +

+

+ Returns: A reference to the Ith element of T. +

+
+template<int I, typename T>
+PJ get(T const& t);
+
+

+ Requires: 0 < I <= N. + The program is ill formed if I + is out of bounds. T is + any fusion sequence type, including tuple. +

+

+ Return type: PJ + is equivalent to result_of::at_c<I,T>::type. +

+

+ Returns: A const reference to the Ith element of T. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple/relational_operators.html b/doc/html/fusion/tuples/class_template_tuple/relational_operators.html new file mode 100644 index 00000000..7b2e0296 --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple/relational_operators.html @@ -0,0 +1,191 @@ + + + +Relational + operators + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ The TR1 + Tuple provides the standard boolean relational operators. +

+
+ + Specification +
+
+

Notation

+
+
T1 + ... TN, + U1 ... + UN
+
+ Tuple element types +
+
P1 + ... PN
+
+ Parameter types +
+
Ti, + Ui
+
+ The type of the ith element + of a tuple +
+
Pi
+
+ The type of the ith parameter +
+
+
+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator==(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(lhs) == get<i>(rhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns true + if and only if get<i>(lhs) == get<i>(rhs) + for all i. For any 2 zero + length tuples e and f, e == f + returns true. +

+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator<(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(lhs) < get<i>(rhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns the lexicographical + comparison of between lhs + and rhs. +

+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator!=(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(lhs) == get<i>(rhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns !(lhs == rhs). +

+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator<=(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(rhs) < get<i>(lhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns !(rhs < lhs) +

+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator>(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(rhs) < get<i>(lhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns rhs < lhs. +

+
+template<typename T1, typename T2, ..., typename TN,
+         typename U1, typename U2, ..., typename UN>
+bool operator>=(
+    const tuple<T1, T2, ..., TN>& lhs,
+    const tuple<U1, U2, ..., UN>& rhs);
+
+

+ Requirements: For all i, + 1 <= i < N, get<i>(lhs) < get<i>(rhs) + is a valid expression returning a type that is convertible to bool. +

+

+ Semantics: Returns !(lhs < rhs). +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple/tuple_creation_functions.html b/doc/html/fusion/tuples/class_template_tuple/tuple_creation_functions.html new file mode 100644 index 00000000..6b73088b --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple/tuple_creation_functions.html @@ -0,0 +1,79 @@ + + + +Tuple + creation functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ TR1 describes 2 utility functions for creating _tr1tuple_s. make_tuple + builds a tuple out of it's argument list, and tie + builds a tuple of references to it's arguments. The details of these creation + functions are described in this section. +

+
+ + Specification +
+
+template<typename T1, typename T2, ..., typename TN>
+tuple<V1, V2, ..., VN> make_tuple(const T1& t1, const T2& t2, ..., const TN& tn);
+
+

+ Where Vi is X& + if the cv-unqualified type Ti + is reference_wrapper<X>, + otherwise Vi is Ti. +

+

+ Returns: tuple<V1, V2, ..., VN>(t1, t2, ..., tN) +

+
+template<typename T1, typename T2, ..., typename TN>
+tuple<T1&, T2&, ..., TN&> tie(T1& t1, T2& t2, ..., TN& tn);
+
+

+ Returns: tuple<T1&, T2&, ..., + TN&>(t1, t2, ..., tN). When argument ti + is ignore, assigning any + value to the corresponding tuple element has has no effect. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/class_template_tuple/tuple_helper_classes.html b/doc/html/fusion/tuples/class_template_tuple/tuple_helper_classes.html new file mode 100644 index 00000000..9062b1a2 --- /dev/null +++ b/doc/html/fusion/tuples/class_template_tuple/tuple_helper_classes.html @@ -0,0 +1,83 @@ + + + +Tuple + helper classes + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Description +
+

+ The TR1 + Tuple provides 2 helper traits, for compile time access to the + tuple size, and the element types. +

+
+ + Specification +
+
+tuple_size<T>::value
+
+

+ Requires: T + is any fusion sequence type, including tuple. +

+

+ Type: MPL Integral Constant +

+

+ Value: The number of elements in the sequence. + Equivalent to result_of::size<T>::type. +

+
+tuple_element<I, T>::type
+
+

+ Requires: T + is any fusion sequence type, including tuple. + 0 <= I < N or the program is ill formed. +

+

+ Value: The type of the Ith + element of T. Equivalent + to result_of::value_at<I,T>::type. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/fusion/tuples/pairs.html b/doc/html/fusion/tuples/pairs.html new file mode 100644 index 00000000..72e067ab --- /dev/null +++ b/doc/html/fusion/tuples/pairs.html @@ -0,0 +1,101 @@ + + + +Pairs + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ + Description +

+

+ The TR1 + Tuple interface is specified to provide uniform access to std::pair + as if it were a 2 element tuple. +

+

+ + Specification +

+
+tuple_size<std::pair<T1, T2> >::value
+
+

+ Type: An MPL Integral Constant +

+

+ Value: Returns 2, the number of elements + in a pair. +

+
+tuple_element<0, std::pair<T1, T2> >::type
+
+

+ Type: T1 +

+

+ Value: Returns the type of the first element + of the pair +

+
+tuple_element<1, std::pair<T1, T2> >::type
+
+

+ Type: T2 +

+

+ Value: Returns thetype of the second element + of the pair +

+
+template<int I, typename T1, typename T2>
+P& get(std::pair<T1, T2>& pr);
+
+template<int I, typename T1, typename T2>
+const P& get(const std::pair<T1, T2>& pr);
+
+

+ Type: If I == 0 P is T1, + else if I == 1 P + is T2 else the program is + ill-formed. +

+

+ Returns: pr.first + if I == 0 else pr.second.[*Returns: + pr.first if I == 0 else + pr.second. +

+
+ + + +
Copyright © 2001-2005 Joel de Guzman, Dan Marsden
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/images/alert.png b/doc/html/images/alert.png new file mode 100755 index 00000000..b4645bc7 Binary files /dev/null and b/doc/html/images/alert.png differ diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png new file mode 100644 index 00000000..5b7809ca Binary files /dev/null and b/doc/html/images/caution.png differ diff --git a/doc/html/images/fusion_org.png b/doc/html/images/fusion_org.png new file mode 100644 index 00000000..3bb56539 Binary files /dev/null and b/doc/html/images/fusion_org.png differ diff --git a/doc/html/images/home.png b/doc/html/images/home.png new file mode 100755 index 00000000..5584aacb Binary files /dev/null and b/doc/html/images/home.png differ diff --git a/doc/html/images/important.png b/doc/html/images/important.png new file mode 100644 index 00000000..12c90f60 Binary files /dev/null and b/doc/html/images/important.png differ diff --git a/doc/html/images/next.png b/doc/html/images/next.png new file mode 100755 index 00000000..59800b4e Binary files /dev/null and b/doc/html/images/next.png differ diff --git a/doc/html/images/note.png b/doc/html/images/note.png new file mode 100755 index 00000000..3ed047ca Binary files /dev/null and b/doc/html/images/note.png differ diff --git a/doc/html/images/prev.png b/doc/html/images/prev.png new file mode 100755 index 00000000..d88a40f9 Binary files /dev/null and b/doc/html/images/prev.png differ diff --git a/doc/html/images/smiley.png b/doc/html/images/smiley.png new file mode 100755 index 00000000..30a77f71 Binary files /dev/null and b/doc/html/images/smiley.png differ diff --git a/doc/html/images/tip.png b/doc/html/images/tip.png new file mode 100755 index 00000000..9f596b0b Binary files /dev/null and b/doc/html/images/tip.png differ diff --git a/doc/html/images/up.png b/doc/html/images/up.png new file mode 100755 index 00000000..17d9c3ec Binary files /dev/null and b/doc/html/images/up.png differ diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png new file mode 100644 index 00000000..1c33db8f Binary files /dev/null and b/doc/html/images/warning.png differ diff --git a/doc/html/index.html b/doc/html/index.html new file mode 100644 index 00000000..2d4024f4 --- /dev/null +++ b/doc/html/index.html @@ -0,0 +1,66 @@ + + + +Chapter 1. Fusion 2.0 + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
Next
+
+
+

+Chapter 1. Fusion 2.0

+

+Joel de Guzman +

+

+Dan Marsden +

+
+
+

+ Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +

+
+
+ +
+ + + +

Last revised: August 16, 2006 at 16:16:24 GMT

+
+
Next
+ + diff --git a/doc/introduction.qbk b/doc/introduction.qbk new file mode 100644 index 00000000..d8f3f880 --- /dev/null +++ b/doc/introduction.qbk @@ -0,0 +1,81 @@ +[section Introduction] + +An advantage other languages such as Python and Lisp/ Scheme, ML and +Haskell, etc., over C++ is the ability to have heterogeneous containers +that can hold arbitrary element types. All the containers in the standard +library can only hold a specific type. A `vector` can only hold +`int`s. A `list` can only hold elements of type `X`, and so on. + +True, you can use inheritance to make the containers hold different types, +related through subclassing. However, you have to hold the objects through +a pointer or smart reference of some sort. Doing this, you'll have to rely +on virtual functions to provide polymorphic behavior since the actual type +is erased as soon as you store a pointer to a derived class to a pointer to +its base. The held objects must be related: you cannot hold objects of +unrelated types such as `char`, `int`, `class X`, `float`, etc. Oh sure you +can use something like __boost_any__ to hold arbitrary types, but then you +pay more in terms of runtime costs and due to the fact that you practically +erased all type information, you'll have to perform dangerous casts to get +back the original type. + +The __tuple__ library written by __jaakko_jarvi__ provides heterogeneous +containers in C++. The `tuple` is a basic data structure that can hold +heterogeneous types. It's a good first step, but it's not complete. What's +missing are the algorithms. It's nice that we can store and retrieve data +to and from tuples, pass them around as arguments and return types. As it +is, the __tuple__ facility is already very useful. Yet, as soon as you use +it more often, usage patterns emerge. Eventually, you collect these +patterns into algorithm libraries. + +Hmmm, kinda reminds us of STL right? Right! Can you imagine how it would be +like if you used STL without the algorithms? Everyone will have to reinvent +their own /algorithm/ wheels. + +Fusion is a library and a framework similar to both __stl__ and the boost +__mpl__. The structure is modeled after __mpl__, which is modeled +after __stl__. It is named "fusion" because the library is reminiscent of +the "fusion" of compile time meta-programming with runtime programming. The +library inherently has some interesting flavors and characteristics of both +__mpl__ and __stl__. It lives in the twilight zone between compile time +meta-programming and run time programming. __stl__ containers work on +values. MPL containers work on types. Fusion containers work on both types +and values. + +Unlike __mpl__, Fusion algorithms are lazy and non sequence-type +preserving. What does that mean? It means that when you operate on a +sequence through a Fusion algorithm that returns a sequence, the sequence +returned may not be of the same class as the original. This is by design. +Runtime efficiency is given a high priority. Like __mpl__, and unlike +__stl__, fusion algorithms are functional in nature such that algorithms +are non mutating (no side effects). However, due to the high cost of +returning full sequences such as vectors and lists, /Views/ are returned +from Fusion algorithms instead. For example, the __transform__ algorithm +does not actually return a transformed version of the original sequence. +__transform__ returns a __transform_view__. This view holds a reference to +the original sequence plus the transform function. Iteration over the +__transform_view__ will apply the transform function over the sequence +elements on demand. This /lazy/ evaluation scheme allows us to chain as +many algorithms as we want without incurring a high runtime penalty. + +The /lazy/ evaluation scheme where algorithms return views allows +operations such as __push_back__ to be totally generic. In Fusion, +__push_back__ is actually a generic algorithm that works on all sequences. +Given an input sequence `s` and a value `x`, Fusion's __push_back__ +algorithm simply returns a __joint_view__: a view that holds a reference to +the original sequence `s` and the value `x`. Functions that were once +sequence specific and need to be implemented N times over N different +sequences are now implemented only once. + +Fusion provides full round compatibility with __mpl__. Fusion sequences are +fully conforming __mpl__ sequences and __mpl__ sequences are fully +compatible with Fusion. You can work with Fusion sequences on __mpl__ if +you wish to work solely on types. In __mpl__, Fusion sequences follow +__mpl__'s sequence-type preserving semantics (i.e. algorithms preserve the +original sequence type. e.g. transforming a vector returns a vector). You +can also convert from an __mpl__ sequence to a Fusion sequence. For +example, there are times when it is convenient to work solely on __mpl__ +using pure __mpl__ sequences, then, convert them to Fusion sequences as a +final step before actual instantiation of real runtime objects with data. +You have the best of both worlds. + +[endsect] diff --git a/doc/iterators.qbk b/doc/iterators.qbk new file mode 100644 index 00000000..1607242a --- /dev/null +++ b/doc/iterators.qbk @@ -0,0 +1,855 @@ +[section Iterators] +Like __mpl__ and __stl__, iterators are a fundamental concept in Fusion. +As with __mpl__ and __stl__ iterators describe positions, and +provide access to data within an underlying __sequence__. + +[heading Header] + #include + +[section Concepts] + +Fusion iterators are divided into different traversal categories. +__forward_iterator__ is the most basic concept. __bidirectional_iterator__ +is a refinement of __forward_iterator__. __random_access_iterator__ is a +refinement of __bidirectional_iterator__. + +[section Forward Iterator] + +[heading Description] +A Forward Iterator traverses a __sequence__ allowing movement in only one direction through +it's elements, one element at a time. + +[variablelist Notation + [[`i`, `j`] [Forward Iterators]] + [[`I`, `J`] [Forward Iterator types]] + [[`M`] [An __mpl__ integral constant]] + [[`N`] [An integral constant]] +] + +[heading Expression requirements] +A type models Forward Iterator if, in addition to being CopyConstructable, +the following expressions are valid: + +[table + [[Expression] [Return type] [Runtime Complexity]] + [[`__next__(i)`] [__forward_iterator__] [Constant]] + [[`i == j`] [Convertible to bool] [Constant]] + [[`i != j`] [Convertible to bool] [Constant]] + [[`__advance_c__(i)`] [__forward_iterator__] [Constant]] + [[`__advance__(i)`] [__forward_iterator__] [Constant]] + [[`__distance__(i, j)`] [`__result_of_distance__::type`][Constant]] + [[`__deref__(i)`] [`__result_of_deref__::type`] [Constant]] + [[`*i`] [`__result_of_deref__::type`] [Constant]] +] + +[heading Meta Expressions] +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_next__::type`] [Amortized constant time]] + [[`__result_of_equal_to__::type`] [Amortized constant time]] + [[`__result_of_advance_c__::type`] [Linear]] + [[`__result_of_advance__::type`] [Linear]] + [[`__result_of_distance__::type`] [Linear]] + [[`__result_of_deref__::type`] [Amortized constant time]] + [[`__result_of_value_of__::type`] [Amortized constant time]] +] + +[heading Expression Semantics] +[ +table + [[Expression] [Semantics]] + [[`__next__(i)`] [An iterator to the element following `i`]] + [[`i == j`] [Iterator equality comparison]] + [[`i != j`] [Iterator inequality comparison]] + [[`__advance_c__(i)`] [An iterator n elements after `i` in the sequence]] + [[`__advance__(i)`] [Equivalent to `advance_c(i)`]] + [[`__distance__(i, j)`] [The number of elements between `i` and `j`]] + [[`__deref__(i)`] [The element at position`i`]] + [[`*i`] [Equivalent to `deref(i)`]] +] + +[heading Invariants] +The following invariants always hold: + +* `!(i == j) == (i != j)` +* `__next__(i) == __advance_c__<1>(i)` +* `__distance__(i, __advance_c__(i)) == N` +* Using `__next__` to traverse the sequence will never return to a previously seen position +* `__deref__(i)` is equivalent to `*i` +* If `i == j` then `*i` is equivalent to `*j` + +[heading Models] +* __std_pair__ iterator +* __boost_array__ iterator +* __vector__ iterator +* __cons__ iterator +* __list__ iterator +* __set__ iterator +* __map__ iterator +* __single_view__ iterator +* __filter_view__ iterator +* __iterator_range__ iterator +* __joint_view__ iterator +* __transform_view__ iterator +* __reverse_view__ iterator + +[endsect] + +[section Bidirectional Iterator] +[heading Description] +A Bidirectional Iterator traverses a __sequence__ allowing movement in either direction one +element at a time. + +[variablelist Notation + [[`i`] [A Bidirectional Iterator]] + [[`I`] [A Bidirectional Iterator type]] + [[`M`] [An __mpl__ integral constant]] + [[`N`] [An integral constant]] +] + +[heading Refinement of] +__forward_iterator__ + +[heading Expression requirements] +In addition to the requirements defined in __forward_iterator__, +the following expressions must be valid: + +[table + [[Expression] [Return type] [Runtime Complexity]] + [[`__next__(i)`] [__bidirectional_iterator__] [Constant]] + [[`__prior__(i)`] [__bidirectional_iterator__] [Constant]] + [[`__advance_c__(i)`] [__bidirectional_iterator__] [Constant]] + [[`__advance__(i)`] [__bidirectional_iterator__] [Constant]] +] + +[heading Meta Expressions] +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_prior__::type`] [Amortized constant time]] +] + +[heading Expression Semantics] +The semantics of an expression are defined only where they differ from, or are not defined +in __forward_iterator__ + +[table + [[Expression] [Semantics]] + [[`__prior__(i)`] [An iterator to the element preceding `i`]] +] + +[heading Invariants] +In addition to the invariants of __forward_iterator__, +the following invariants always hold: + +* `__prior__(__next__(i)) == i && __prior__(__next__(i)) == __next__(__prior__(i))` +* `__prior__(i) == __advance_c__<-1>(i)` +* Using `__prior__` to traverse a sequence will never return a previously seen position + +[heading Models] +* __std_pair__ iterator +* __boost_array__ iterator +* __vector__ iterator +* __iterator_range__ (where adapted sequence is a __bidirectional_sequence__) +* __transform_view__ (where adapted sequence is a __bidirectional_sequence__) +* __reverse_view__ + +[endsect] + +[section Random Access Iterator] +[heading Description] +A Random Access Iterator traverses a __sequence__ moving in either direction, +permitting efficient arbitrary distance movements back and forward through the +sequence. + +[variablelist Notation + [[`i`, `j`] [Random Access Iterators]] + [[`I`, `J`] [Random Access Iterator types]] + [[`M`] [An __mpl__ integral constant]] + [[`N`] [An integral constant]] +] + +[heading Refinement of] +__bidirectional_iterator__ + +[heading Expression requirements] +In addition to the requirements defined in __bidirectional_iterator__, +the following expressions must be valid: + +[table + [[Expression] [Return type] [Runtime Complexity]] + [[`__next__(i)`] [__random_access_iterator__] [Constant]] + [[`__prior__(i)`] [__random_access_iterator__] [Constant]] + [[`__advance_c__(i)`] [__random_access_iterator__] [Constant]] + [[`__advance__(i)`] [__random_access_iterator__] [Constant]] +] + +[heading Meta Expressions] +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_advance_c__::type`] [Amortized constant time]] + [[`__result_of_advance__::type`] [Amortized constant time]] + [[`__result_of_distance__::type`] [Amortized constant time]] +] + +[heading Models] +* __vector__ iterator +* __std_pair__ iterator +* __boost_array__ iterator +* __iterator_range__ iterator (where adapted sequence is a __random_access_sequence__) +* __transform_view__ iterator (where adapted sequence is a __random_access_sequence__) +* __reverse_view__ iterator (where adapted sequence is a __random_access_sequence__) + +[endsect] + +[endsect] + +[section Functions] +Fusion provides functions for manipulating iterators, analogous to the similar functions +from the __mpl__ library. + +[section deref] + +[heading Description] +Deferences an iterator. + +[heading Synopsis] + template< + typename I + > + typename __result_of_deref__::type deref(I const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __deref__(i); + +[*Return type]: `__result_of_deref__::type` + +[*Semantics]: Dereferences the iterator `i`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + int i(0); + vec v(1,i); + assert(__deref__(__begin__(v)) == 1); + assert(__deref__(__next__(__begin__(v))) == 0); + assert(&(__deref__(__next__(__begin__(v)))) == &i); + +[endsect] + +[section next] + +[heading Description] +Moves an iterator 1 position forwards. + +[heading Synopsis] + template< + typename I + > + typename __result_of_next__::type next(I const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + next(i); + +[*Return type]: A model of the same iterator concept as `i`. + +[*Semantics]: Returns an iterator to the next element after `i`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + vec v(1,2,3); + assert(__deref__(__begin__(v)) == 1); + assert(__deref__(__next__(__begin__(v))) == 2); + assert(__deref__(__next__(__next__(__begin__(v)))) == 3); + +[endsect] + +[section prior] + +[heading Description] +Moves an iterator 1 position backwards. + +[heading Synopsis] + template< + typename I + > + typename __result_of_prior__::type prior(I const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __bidirectional_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __prior__(i); + +[*Return type]: A model of the same iterator concept as `i`. + +[*Semantics]: Returns an iterator to the element prior to `i`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + vec v(1,2); + assert(__deref__(__next__(__begin__(v))) == 2); + assert(__deref__(__prior__(__next__(__begin__(v)))) == 1); + +[endsect] + +[section distance] + +[heading Description] +Returns the distance between 2 iterators. + +[heading Synopsis] + template< + typename I, + typename J + > + typename __result_of_distance__::type distance(I const& i, J const& j); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`, `j`] [Models of __forward_iterator__ into the same sequence] [The start and end points of the distance to be measured]] +] + +[heading Expression Semantics] + __distance__(i,j); + +[*Return type]: `int` + +[*Semantics]: Returns the distance between iterators `i` and `j`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + vec v(1,2,3); + assert(__distance__(__begin__(v), __next__(__next__(__begin__(v)))) == 2); + +[endsect] + +[section advance] + +[heading Description] +Moves an iterator by a specified distance. + +[heading Synopsis] + template< + typename I, + typename M + > + typename __result_of_advance__::type advance(I const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __forward_iterator__] [Iterator to move relative to]] + [[`N`] [An __mpl_integral_constant__] [Number of positions to move]] +] + +[heading Expression Semantics] + __advance__(i); + +[*Return type]: A model of the same iterator concept as `i`. + +[*Semantics]: Returns an iterator to the element `M` positions from `i`. If `i` is a __bidirectional_iterator__ then `M` may be negative. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + vec v(1,2,3); + assert(__deref__(__advance__ >(__begin__(v))) == 3); + +[endsect] + +[section advance_c] + +[heading Description] +Moves an iterator by a specified distance. + +[heading Synopsis] + template< + typename I, + int N + > + typename __result_of_advance_c__::type advance_c(I const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __forward_iterator__] [Iterator to move relative to]] + [[`N`] [Integer constant] [Number of positions to move]] +] + +[heading Expression Semantics] + __advance_c__(i); + +[*Return type]: A model of the same iterator concept as `i`. + +[*Semantics]: Returns an iterator to the element `N` positions from `i`. If `i` is a __bidirectional_iterator__ then `N` may be negative. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + vec v(1,2,3); + assert(__deref__(__advance_c__<2>(__begin__(v))) == 3); + +[endsect] + +[endsect] + +[section Operators] +Overloaded operators are provided to provide a more natural syntax for dereferencing iterators, and comparing them for equality. + +[section:operator_unary_star Operator *] + +[heading Description] +Dereferences an iterator. + +[heading Synopsis] + template< + typename I + > + typename __result_of_deref__::type operator*(__unspecified__ const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + *i + +[*Return type]: Equivalent to the return type of `__deref__(i)`. + +[*Semantics]: Equivalent to `__deref__(i)`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + + int i(0); + vec v(1,i); + assert(*__begin__(v) == 1); + assert(*__next__(__begin__(v)) == 0); + assert(&(*__next__(__begin__(v))) == &i); + +[endsect] + +[section:operator_equality Operator ==] + +[heading Description] +Compares 2 iterators for equality. + +[heading Synopsis] + template< + typename I, + typename J + > + __unspecified__ operator==(I const& i, J const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`, `j`] [Any fusion iterators] [Operation's arguments]] +] + +[heading Expression Semantics] + i == j + +[*Return type]: Convertible to `bool`. + +[*Semantics]: Equivalent to `__result_of_equal_to__::value` where `I` and `J` are the types of `i` and `j` respectively. + +[heading Header] + #include + +[endsect] + +[section:operator_inequality Operator !=] + +[heading Description] +Compares 2 iterators for inequality. + +[heading Synopsis] + template< + typename I, + typename J + > + __unspecified__ operator==(I const& i, J const& i); + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`i`, `j`] [Any fusion iterators] [Operation's arguments]] +] + +[heading Expression Semantics] + +[*Return type]: Convertible to `bool`. + +[*Semantics]: Equivalent to `!__result_of_equal_to__::value` where `I` and `J` are the types of `i` and `j` respectively. + +[heading Header] + #include + +[endsect] + +[endsect] + +[section Metafunctions] + +[section value_of] + +[heading Description] + +Returns the type stored at the position of an iterator. + +[heading Synopsis] + template< + typename I + > + struct value_of + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_value_of__::type + +[*Return type]: Any type + +[*Semantics]: Returns the type stored in a sequence at iterator position `I`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type first; + typedef __result_of_next__::type second; + typedef __result_of_next__::type third; + + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, int>)); + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, int&>)); + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, const int&>)); + +[endsect] + +[section deref] + +[heading Description] +Returns the type that will be returned by dereferencing an iterator. + +[heading Synposis] + template< + typename I + > + struct deref + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_deref__::type + +[*Return type]: Any type + +[*Semantics]: Returns the result of dereferencing an iterator of type `I`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef const vec const_vec; + typedef __result_of_begin__::type first; + typedef __result_of_next__::type second; + + typedef __result_of_begin__::type const_first; + typedef __result_of_next__::type const_second; + + BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__::type, int&>)); + BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__::type, int&>)); + +[endsect] + +[section next] + +[heading Description] +Returns the type of the next iterator in a sequence. + +[heading Synposis] + template< + typename I + > + struct next + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __forward_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_next__::type + +[*Return type]: A model of the same iterator concept as `I`. + +[*Semantics]: Returns an iterator to the next element in the sequence after `I`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_next__<__result_of_begin__::type>::type second; + + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, double>)); + +[endsect] + +[section prior] + +[heading Description] +Returns the type of the previous iterator in a sequence. + +[heading Synopsis] + template< + typename I + > + struct prior + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __bidirectional_iterator__] [Operation's argument]] +] + +[heading Expression Semantics] + __result_of_prior__::type + +[*Return type]: A model of the same iterator concept as `I`. + +[*Semantics]: Returns an iterator to the previous element in the sequence before `I`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_next__<__result_of_begin__::type>::type second; + + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, double>)); + + typedef __result_of_prior__::type first; + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__::type, int>)); + +[endsect] + +[section equal_to] + +[heading Description] +Returns a true-valued __mpl_integral_constant__ if `I` and `J` are equal. + +[heading Synopsis] + template< + typename I, + typename J + > + struct equal_to + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`, `J`] [Any fusion iterators] [Operation's arguments]] +] + +[heading Expression Semantics] + __result_of_equal_to__::type + +[*Return type]: A model of __mpl_integral_constant__. + +[*Semantics]: Returns `boost::mpl::true_` if `I` and `J` are iterators to the same position. Returns `boost::mpl::false_` otherwise. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type first; + typedef __result_of_end__::type last; + BOOST_MPL_ASSERT((__result_of_equal_to__)); + BOOST_MPL_ASSERT_NOT((__result_of_equal_to__)); + +[endsect] + +[section distance] + +[heading Description] +Returns the distance between two iterators. + +[heading Synopsis] + template< + typename I, + typename J + > + struct distance + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`, `J`] [Models of __forward_iterator__ into the same sequence] [The start and end points of the distance to be measured]] +] + +[heading Expression Semantics] + __result_of_distance__::type + +[*Return type]: A model of __mpl_integral_constant__. + +[*Semantics]: Returns the distance between iterators of types `I` and `J`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type first; + typedef __result_of_next__::type second; + typedef __result_of_next__::type third; + typedef __result_of_distance__::type dist; + + BOOST_MPL_ASSERT_RELATION(dist::value, ==, 2); + +[endsect] + +[section advance] + +[heading Description] +Moves an iterator a specified distance. + +[heading Synopsis] + template< + typename I, + typename M + > + struct advance + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __forward_iterator__] [Iterator to move relative to]] + [[`M`] [Model of __mpl_integral_constant__] [Number of positions to move]] +] + +[heading Expression Semantics] + __result_of_advance__::type + +[*Return type]: A model of the same iterator concept as `I`. + +[*Semantics]: Returns an iterator a distance `M` from `I`. If `I` is a __bidirectional_iterator__ then `M` may be negative. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type first; + typedef __result_of_next__::type second; + typedef __result_of_next__::type third; + + BOOST_MPL_ASSERT((__result_of_equal_to__<__result_of_advance__ >::type, third>)); + +[endsect] + +[section advance_c] + +[heading Description] +Moves an iterator by a specified distance. + +[heading Synopsis] + template< + typename I, + int N + > + struct advance_c + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`I`] [Model of __forward_iterator__] [Iterator to move relative to]] + [[`N`] [Integer constant] [Number of positions to move]] +] + +[heading Expression Semantics] + __result_of_advance_c__::type + +[*Return type]: A model of the same iterator concept as `I`. + +[*Semantics]: Returns an iterator a distance `N` from `I`. If `I` is a __bidirectional_iterator__ then `N` may be negative. Equivalent to `__result_of_advance__ >::type`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type first; + typedef __result_of_next__::type second; + typedef __result_of_next__::type third; + + BOOST_MPL_ASSERT((__result_of_equal_to__<__result_of_advance_c__::type, third>)); + +[endsect] + +[endsect] + +[endsect] + diff --git a/doc/notes.qbk b/doc/notes.qbk new file mode 100644 index 00000000..f6fab805 --- /dev/null +++ b/doc/notes.qbk @@ -0,0 +1,146 @@ +[section Notes] + +[heading Recursive Inlined Functions] + +An interesting peculiarity of functions like __at__ when applied to a +__forward_sequence__ like __list__ is that what could have been linear +runtime complexity effectively becomes constant O(1) due to compiler +optimization of C++ inlined functions, however deeply recursive (up to a +certain compiler limit of course). Compile time complexity remains linear. + +[heading Overloaded Functions] + +Associative sequences use function overloading to implement membership +testing and type associated key lookup. This amounts to constant runtime +and amortized constant compile time complexities. There is an overloaded +function, `f(k)`, for each key /type/ `k`. The compiler chooses the +appropriate function given a key, `k`. + +[heading Tag Dispatching] + +Tag dispatching is a generic programming technique for selecting template +specializations. There are typically 3 components involved in the tag +dispatching mechanism: + +# A type for which an appropriate template specialization is required +# A metafunction that associates the type with a tag type +# A template that is specialized for the tag type + +For example, the fusion `result_of::begin` metafunction is implemented +as follows: + + template + struct begin + { + typedef typename + result_of::begin_impl::type>:: + template apply::type + type; + }; + +In the case: + +# `Sequence` is the type for which a suitable implementation of + `result_of::begin_impl` is required +# `traits::tag_of` is the metafunction that associates `Sequence` + with an appropriate tag +# `result_of::begin_impl` is the template which is specialized to provide + an implementation for each tag type + +[heading Extensibility] + +Unlike __mpl__, there is no extensibe sequence concept in fusion. This does +not mean that Fusion sequences are not extensible. In fact, all Fusion +sequences are inherently extensible. It is just that the manner of sequence +extension in Fusion is diferent from both __stl__ and __mpl__ on account of +the lazy nature of fusion __algorithms__. __stl__ containers extend +themselves in place though member functions such as __push_back__ and +__insert__. __mpl__ sequences, on the other hand, are extended through +"intrinsic" functions that actually return whole sequences. __mpl__ is +purely functional and can not have side effects. For example, __mpl__'s +`push_back` does not actually mutate an `mpl::vector`. It can't do that. +Instead, it returns an extended `mpl::vector`. + +Like __mpl__, Fusion too is purely functional and can not have side +effects. With runtime efficiency in mind, Fusion sequences are extended +through generic functions that return __views__. __views__ are sequences +that do not actually contain data, but instead impart an alternative +presentation over the data from one or more underlying sequences. __views__ +are proxies. They provide an efficient yet purely functional way to work on +potentially expensive sequence operations. For example, given a __vector__, +Fusion's __push_back__ returns a __joint_view__, instead of an actual +extended __vector__. A __joint_view__ holds a reference to the original +sequence plus the appended data --making it very cheap to pass around. + +[heading Element Conversion] + +Functions that take in elemental values to form sequences (e.g. +__make_list__) convert their arguments to something suitable to be stored +as a sequence element. In general, the element types are stored as plain +values. Example: + + __make_list__(1, 'x') + +returns a __list__``. + +There are a few exceptions, however. + +[*Arrays:] + +Array arguments are deduced to reference to const types. For example +[footnote Note that the type of a string literal is an array of const +characters, not `const char*`. To get __make_list__ to create a __list__ +with an element of a non-const array type one must use the `ref` wrapper +(see __note_boost_ref__).]: + + __make_list__("Donald", "Daisy") + +creates a __list__ of type + + __list__ + +[*Function pointers:] + +Function pointers are deduced to the plain non-reference type (i.e. to +plain function pointer). Example: + + void f(int i); + ... + __make_list__(&f); + +creates a __list__ of type + + __list__ + +[heading boost::ref] + +Fusion's generation functions (e.g. __make_list__) by default stores the +element types as plain non-reference types. Example: + + void foo(const A& a, B& b) { + ... + __make_list__(a, b) + +creates a __list__ of type + + __list__ + +Sometimes the plain non-reference type is not desired. You can use +`boost::ref` and `boost::cref` to store references or const references +(respectively) instead. The mechanism does not compromise const correctness +since a const object wrapped with ref results in a tuple element with const +reference type (see the fifth code line below). Examples: + +For example: + + A a; B b; const A ca = a; + __make_list__(cref(a), b); // creates list + __make_list__(ref(a), b); // creates list + __make_list__(ref(a), cref(b)); // creates list + __make_list__(cref(ca)); // creates list + __make_list__(ref(ca)); // creates list + +See __boost_ref__ for details. + +[endsect] + diff --git a/doc/organization.qbk b/doc/organization.qbk new file mode 100644 index 00000000..cff048f8 --- /dev/null +++ b/doc/organization.qbk @@ -0,0 +1,68 @@ +[section Organization] + +The library is organized into layers of modules, with each module addressing a particular +area of responsibility. A module may not depend on modules in higher layers. + +The library is organized in three layers: + +[heading Layers] + +[:[$images/fusion_org.png]] + +The entire library is found in the "boost/fusion" directory. Modules are +organized in directories. Each module has its own header file placed in the +same directory with the actual module-directory. For example, there exists +"boost/fusion/support.hpp" in the same directory as "boost/fusion/support". +Everything, except those found inside "detail" directories, is public. The +library is header-only. There is no need to build object files to link +against. + +[heading Directory] + +* tuple +* algorithm + * iteration + * query + * transformation +* sequence + * adapted + * array + * mpl + * std_pair + * comparison + * container + * list + * map + * set + * vector + * conversion + * generation + * intrinsic + * io + * utility + * view + * filter_view + * iterator_range + * joint_view + * reverse_view + * single_view + * transform_view + * zip_view +* iterator +* support + +[heading Example] + +If, for example, you want to use `list`, depending on the granularity that +you desire, you may do so by including one of + + #include + #include + #include + +The first includes all sequences. The second includes all of sequence +containers. The third includes only `list` [footnote Modules may contain +smaller components. Header file information for each component will be +provided as part of the component's documentation.]. + +[endsect] diff --git a/doc/preface.qbk b/doc/preface.qbk new file mode 100644 index 00000000..1c838c66 --- /dev/null +++ b/doc/preface.qbk @@ -0,0 +1,68 @@ +[section Preface] + +[:['["Algorithms + Data Structures = Programs.]]] +[:*--Niklaus Wirth*] + +[heading Description] + +Fusion is a library for working with hetrogenous collections of data, +commonly referred to as tuples. A set of containers (vector, list, set and map) +is provided, along with views that provide a transformed presentation +of their underlying data. Collectively the containers and views are referred to +as sequences, and Fusion has a suite of algorithms that operate upon the +various sequence types, using an iterator concept that binds everything +together. + +The architecture is modeled after __mpl__ which in turn is modeled after +__stl__. It is named "fusion" because the library is a "fusion" of compile +time metaprogramming with runtime programming. + +[heading Motivation] + +Tuples are powerful beasts. After having developed two significant projects +(__spirit__ and __phoenix__) that relied heavily metaprogramming, it +became apparent that tuples are a powerful means to simplify otherwise tricky +tasks; especially those that require a combination of metaprogramming and +manipulation of heterogenous data types with values. While __mpl__ is an +extremely powerful metaprogramming tool, __mpl__ focuses on type +manipulation only. Ultimately, you'll have to map these types to real +values to make them useful in the runtime world where all the real action +takes place. + +As __spirit__ and __phoenix__ evolved, patterns and idioms related to tuple +manipulation emerged. Soon, it became clear that those patterns and idioms +were best assembled in a tuples algorithms library. __david_abrahams__ +outlined such a scheme in 2002. At that time, it just so happened that +__spirit__ and __phoenix__ had an adhoc collection of tuple manipulation +and traversal routines. It was an instant /AHA!/ moment. + +[heading How to use this manual] + +Some icons are used to mark certain topics indicative of their relevance. +These icons precede some text to indicate: + +[table Icons + [[Icon] [Name] [Meaning]] + [[__note__] [Note] [Information provided is auxiliary but will + give the reader a deeper insight into a specific + topic. May be skipped.]] + [[__alert__] [Alert] [Information provided is of utmost importance.]] + [[__caution__] [Caution] [A mild warning.]] + [[__tip__] [Tip] [A potentially useful and helpful piece of + information.]] +] + +This documentation is automatically generated by Boost QuickBook documentation +tool. QuickBook can be found in the __boost_tools__. + +[heading Support] + +Please direct all questions to Spirit's mailing list. You can subscribe to the +__spirit_list__. The mailing list has a searchable archive. A search link to +this archive is provided in __spirit__'s home page. You may also read and post +messages to the mailing list through __spirit_general__ (thanks to __gmane__). +The news group mirrors the mailing list. Here is a link to the archives: +__mlist_archive__. + +[endsect] + diff --git a/doc/quick_start.qbk b/doc/quick_start.qbk new file mode 100644 index 00000000..8857b5ea --- /dev/null +++ b/doc/quick_start.qbk @@ -0,0 +1,159 @@ +[section Quick Start] + +I assume the reader is already familiar with tuples (__tuple__) and its +ancestor `std::pair`. The tuple is a generalization of `std::pair` for +multiple heterogeneous elements (triples, quadruples, etc.). The tuple is +more or less a synonym for fusion's `__vector__`. + +For starters, we shall include all of Fusion's __sequence__s [footnote There +are finer grained header files available if you wish to have more control +over which components to include (see section __organization__ for +details).]: + + #include + +Let's begin with a `__vector__` [footnote Unless otherwise noted, components are +in namespace `boost::fusion`. For the sake of simplicity, code in this +quick start implies `using` directives for the fusion components we will be +using.]: + + __vector__ stuff(1, 'x', "howdy"); + int i = __at_c__<0>(stuff); + char ch = __at_c__<1>(stuff); + std::string s = __at_c__<2>(stuff); + +Just replace `tuple` for `__vector__` and `get` for `__at_c__` and this is exactly +like __tuple__. Actually, either names can be used interchangeably. Yet, +the similarity ends there. You can do a lot more with Fusion `__vector__` or +`tuple`. Let's see some examples. + +[heading Print the vector as XML] + +First, let's include the algorithms: + + #include + +Now, let's write a function object that prints XML of the form data +for each member in the tuple. + + struct print_xml + { + template + void operator()(T const& x) const + { + std::cout + << '<' << typeid(x).name() << '>' + << x + << "' + ; + } + }; + +Now, finally: + + __for_each__(stuff, print_xml()); + +That's it! `__for_each__` is a fusion algorithm. It is a generic algorithm +similar to __stl__'s. It iterates over the sequence and calls a user +supplied function. In our case, it calls `print_xml`'s `operator()` for +each element in `stuff`. + +[caution The result of `typeid(x).name()` is platform specific. The code +here is just for exposition. Of course you already know that :-)] + +`__for_each__` is generic. With `print_xml`, you can use it to print just about +any Fusion __sequence__. + +[heading Print only pointers] + +Let's get a little cleverer. Say we wish to write a /generic/ function +that takes in an arbitrary sequence and XML prints only those elements +which are pointers. Ah, easy. First, let's include the `is_pointer` boost +type trait: + + #include + +Then, simply: + + template + void xml_print_pointers(Sequence const& seq) + { + __for_each__(__filter_if__ >(seq), print_xml()); + } + +`__filter_if__` is another Fusion algorithm. It returns a __filter_view__, +a conforming Fusion sequence. This view reflects only those elements that +pass the given predicate. In this case, the predicate is +`boost::is_pointer<_>`. This "filtered view" is then passed to the +__for_each__ algorithm, which then prints the "filtered view" as XML. + +Easy, right? + +[heading Associative tuples] + +Ok, moving on... + +Apart from `__vector__`, fusion has a couple of other sequence types to choose +from. Each sequence has its own characteristics. We have `__list__`, `__set__`, +`__map__`, plus a multitude of `views` that provide various ways to present the +sequences. + +Fusion's `__map__` associate types with elements. It can be used as a cleverer +replacement of the `struct`. Example: + + namespace fields + { + struct name; + struct age; + } + + typedef __map__< + __fusion_pair__ + , __fusion_pair__ > + person; + +`__map__` is an associative sequence. Its elements are Fusion pairs which differ +somewhat from `std::pair`. Fusion pairs only contain one member, with the type of +their second template parameter. The first type parameter of the pair is used as an +index to the associated element in the sequence. For example, given a `a_person` +of type, `person`, you can do: + + using namespace fields; + std::string person_name = __at_key__(a_person); + int person_age = __at_key__(a_person); + +Why go through all this trouble, you say? Well, for one, unlike the +`struct`, we are dealing with a generic data structure. There are a +multitude of facilities available at your disposal provided out of the box +with fusion or written by others. With these facilities, introspection +comes for free, for example. We can write one serialization function (well, +two, if you consider loading and saving) that will work for all your fusion +`__map__`s. Example: + + struct saver + { + template + void operator()(Pair const& data) const + { + some_archive << data.second; + } + }; + + template + void save(Stuff const& stuff) + { + __for_each__(stuff, saver()); + } + +The `save` function is generic and will work for all types of `stuff` +regardless if it is a `person`, a `dog` or a whole `alternate_universe`. + +[heading Tip of the Iceberg] + +And... we've barely scratched the surface! You can compose and expand the +data structures, remove elements from the structures, find specific data +types, query the elements, filter out types for inspection, transform data +structures, etc. What you've seen is just the tip of the iceberg. + +[endsect] + diff --git a/doc/references.qbk b/doc/references.qbk new file mode 100644 index 00000000..840e83a3 --- /dev/null +++ b/doc/references.qbk @@ -0,0 +1,19 @@ +[section References] + +# [@http://boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts], + David Abrahams, Jeremy Siek, Thomas Witt, 2004-11-01. +# [@http://boost.org/libs/tuple/doc/tuple_users_guide.html The Boost Tuple Library], + Jaakko Jarvi, 2001. +# [@http://www.boost.org/libs/spirit/ Spirit Parser Library], + Joel de Guzman, 2001-2006. +# [@http://www.boost.org/libs/mpl/ The Boost MPL Library], + Aleksey Gurtovoy and David Abrahams, 2002-2004. +# [@http://www.boost.org/doc/html/array.html Boost Array], + Nicolai Josuttis, 2002-2004. +# [@http://www.sgi.com/tech/stl/ Standard Template Library Programmer's Guide], + Hewlett-Packard Company, 1994. +# [@http://www.boost.org/doc/html/ref.html Boost.Ref], + Jaakko Jarvi, Peter Dimov, Douglas Gregor, Dave Abrahams, 1999-2002. + +[endsect] + diff --git a/doc/sequences.qbk b/doc/sequences.qbk new file mode 100644 index 00000000..627ed680 --- /dev/null +++ b/doc/sequences.qbk @@ -0,0 +1,3804 @@ +[section Sequences] + +Like __mpl__, the Sequence is a fundamental concept in Fusion. A Sequence +may or may not actually store or contain data. __containers__ are sequences +that hold data. __views__, on the other hand, are sequences that do not +store any data. Instead, they are proxies that impart an alternative +presentation over another sequence. All models of Sequence have an +associated __iterator__ type that can be used to iterate through the +Sequence's elements. + +[heading Header] + + #include + +[section Concepts] + +Fusion Sequences are organized into a hierarchy of concepts. + +[heading Traversal] + +Fusion's sequence traversal related concepts parallel Fusion's +__iterator_concepts__. __forward_sequence__ is the most basic concept. +__bidirectional_sequence__ is a refinement of __forward_sequence__. +__random_access_sequence__ is a refinement of __bidirectional_sequence__. +These concepts pertain to sequence traversal. + +[heading Associativity] + +The __associative_sequence__ concept is orthogonal to traversal. An Associative +Sequence allows efficient retrieval of elements based on keys. + +[section Forward Sequence] + +[heading Description] + +A Forward Sequence is a Sequence whose elements are arranged in a definite +order. The ordering is guaranteed not to change from iteration to +iteration. The requirement of a definite ordering allows the definition of +element-by-element equality (if the container's element type is Equality +Comparable) and of lexicographical ordering (if the container's element +type is LessThan Comparable). + +[variablelist Notation + [[`s`] [A Forward Sequence]] + [[`S`] [A Forward Sequence type]] + [[`o`] [An arbitrary object]] + [[`e`] [A Sequence element]] +] + +[heading Valid Expressions] + +For any Forward Sequence the following expressions must be valid: + +[table + [[Expression] [Return type] [Type Requirements] [Runtime Complexity]] + [[`__begin__(s)`] [__forward_iterator__] [] [Constant]] + [[`__end__(s)`] [__forward_iterator__] [] [Constant]] + [[`__size__(s)`] [__mpl_integral_constant__. + Convertible to int.] [] [Constant]] + [[`__empty__(s)`] [__mpl_boolean_constant__. + Convertible to bool.] [] [Constant]] + [[`__front__(s)`] [Any type] [] [Constant]] + [[`__front__(s) = o`] [Any type] [`s` is mutable and + `e = o`, where `e` + is the first element + in the sequence, is + a valid expression.] [Constant]] +] + +[heading Result Type Expressions] + +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_begin__::type`] [Amortized constant time]] + [[`__result_of_end__::type`] [Amortized constant time]] + [[`__result_of_size__::type`] [Unspecified]] + [[`__result_of_empty__::type`] [Constant time]] + [[`__result_of_front__::type`] [Amortized constant time]] +] + +[heading Expression Semantics] + +[table + [[Expression] [Semantics]] + [[`__begin__(s)`] [An iterator to the first element of the sequence; see __begin__.]] + [[`__end__(s)`] [A past-the-end iterator to the sequence; see __end__.]] + [[`__size__(s)`] [The size of the sequence; see __size__.]] + [[`__empty__(s)`] [A boolean Integral Constant `c` such that + `c::value == true` if and only if the sequence + is empty; see __empty__.]] + [[`__front__(s)`] [The first element in the sequence; see __front__.]] +] + +[heading Invariants] + +For any Forward Sequence s the following invariants always hold: + +* `[__begin__(s), __end__(s))` is always a valid range. +* An __algorithm__ that iterates through the range `[__begin__(s), __end__(s))` + will pass through every element of `s` exactly once. +* `__begin__(s)` is identical to `__end__(s))` if and only if `s` is empty. +* Two different iterations through `s` will access its elements in + the same order. + +[heading Models] + +* __std_pair__ +* __boost_array__ +* __vector__ +* __cons__ +* __list__ +* __set__ +* __map__ +* __single_view__ +* __filter_view__ +* __iterator_range__ +* __joint_view__ +* __transform_view__ +* __reverse_view__ + +[endsect] + +[section Bidirectional Sequence] + +[heading Description] + +A Bidirectional Sequence is a __forward_sequence__ whose iterators model +__bidirectional_iterator__. + +[heading Refinement of] + +__forward_sequence__ + +[variablelist Notation + [[`s`] [A Forward Sequence]] + [[`S`] [A Forward Sequence type]] + [[`o`] [An arbitrary object]] + [[`e`] [A Sequence element]] +] + +[heading Valid Expressions] + +In addition to the requirements defined in __forward_sequence__, for any +Bidirectional Sequence the following must be met: + +[table + [[Expression] [Return type] [Type Requirements] [Runtime Complexity]] + [[`__begin__(s)`] [__bidirectional_iterator__] [] [Constant]] + [[`__end__(s)`] [__bidirectional_iterator__] [] [Constant]] + [[`__back__(s)`] [Any type] [] [Constant]] + [[`__back__(s) = o`] [Any type] [`s` is mutable and + `e = o`, where `e` + is the first element + in the sequence, is + a valid expression.] [Constant]] +] + +[heading Result Type Expressions] + +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_begin__::type`] [Amortized constant time]] + [[`__result_of_end__::type`] [Amortized constant time]] + [[`__result_of_back__::type`] [Amortized constant time]] +] + +[heading Expression Semantics] + +The semantics of an expression are defined only where they differ from, or +are not defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`__back__(s)`] [The last element in the sequence; see __back__.]] +] + +[heading Models] + +* __std_pair__ +* __boost_array__ +* __vector__ +* __iterator_range__ (where adapted sequence is a Bidirectional Sequence) +* __transform_view__ (where adapted sequence is a Bidirectional Sequence) +* __reverse_view__ + +[endsect] + +[section Random Access Sequence] + +[heading Description] + +A Random Access Sequence is a __bidirectional_sequence__ whose iterators +model __random_access_iterator__. It guarantees constant time access to +arbitrary sequence elements. + +[heading Refinement of] + +__bidirectional_sequence__ + +[variablelist Notation + [[`s`] [A Random Access Sequence]] + [[`S`] [A Random Access Sequence type]] + [[`N`] [An integral constant]] + [[`o`] [An arbitrary object]] + [[`e`] [A Sequence element]] +] + +[heading Valid Expressions] + +In addition to the requirements defined in __bidirectional_sequence__, for +any Random Access Sequence the following must be met: + +[table + [[Expression] [Return type] [Type Requirements] [Runtime Complexity]] + [[`__begin__(s)`] [__random_access_iterator__] [] [Constant]] + [[`__end__(s)`] [__random_access_iterator__] [] [Constant]] + [[`__at__(s)`] [Any type] [] [Constant]] + [[`__at__(s) = o`] [Any type] [`s` is mutable and + `e = o`, where `e` + is the first element + in the sequence, is + a valid expression.] [Constant]] +] + +[heading Result Type Expressions] + +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_begin__::type`] [Amortized constant time]] + [[`__result_of_end__::type`] [Amortized constant time]] + [[`__result_of_at__::type`] [Amortized constant time]] + [[`__result_of_value_at__::type`] [Amortized constant time]] +] + +[blurb __note__ `__result_of_at__` returns the actual type returned by +`__at__(s)`. In most cases, this is a reference. Hence, there is no way to +know the exact element type using `__result_of_at__`.The element at `N` +may actually be a reference to begin with. For this purpose, you can use +`__result_of_value_at__`.] + +[heading Expression Semantics] + +The semantics of an expression are defined only where they differ from, or +are not defined in __bidirectional_sequence__. + +[table + [[Expression] [Semantics]] + [[`__at__(s)`] [The Nth element from the beginning of the sequence; see __at__.]] +] + +[heading Models] + +* __std_pair__ +* __boost_array__ +* __vector__ +* __iterator_range__ (where adapted sequence is a Random Access Sequence) +* __transform_view__ (where adapted sequence is a Random Access Sequence) +* __reverse_view__ + +[endsect] + +[section Associative Sequence] + +[heading Description] + +An Associative Sequence allows efficient retrieval of elements based on keys. +Like associative sequences in __mpl__, and unlike associative containers in +__stl__, Fusion associative sequences have no implied ordering relation. +Instead, type identity is used to impose an equivalence relation on keys, and +the order in which sequence elements are traversed during iteration is left +unspecified. In addition, unlike __stl__, Associative Sequences have mutable +iterators. This is due to the fact that there is no associated ordering relation +and the runtime value of the keys themselves do not have any effect on the +associativity of the sequence. + + +[variablelist Notation + [[`s`] [An Associative Sequence]] + [[`S`] [An Associative Sequence type]] + [[`K`] [An arbitrary /key/ type]] + [[`o`] [An arbitrary object]] + [[`e`] [A Sequence element]] +] + +[heading Valid Expressions] + +For any Associative Sequence the following expressions must be valid: + +[table + [[Expression] [Return type] [Type Requirements] [Runtime Complexity]] + [[`__has_key__(s)`] [__mpl_boolean_constant__. + Convertible to bool.] [] [Constant]] + [[`__at_key__(s)`] [Any type] [] [Constant]] + [[`__at_key__(s) = o`] [Any type] [`s` is mutable and + `e = o`, where `e` + is the first element + in the sequence, is + a valid expression.] [Constant]] +] + +[heading Result Type Expressions] + +[table + [[Expression] [Compile Time Complexity]] + [[`__result_of_has_key__::type`] [Amortized constant time]] + [[`__result_of_at_key__::type`] [Amortized constant time]] + [[`__result_of_value_at_key__::type`] [Amortized constant time]] +] + +[blurb __note__ `__result_of_at_key__` returns the actual type returned +by `__at_key__(s)`. In most cases, this is a reference. Hence, there is no +way to know the exact element type using `__result_of_at_key__`.The +element at `K` may actually be a reference to begin with. For this purpose, +you can use `__result_of_value_at_key__`.] + +[heading Expression Semantics] + +[table + [[Expression] [Semantics]] + [[`__has_key__(s)`] [A boolean Integral Constant `c` such that + `c::value == true` if and only if there is + one or more elements with the key `k` in `s`; + see __has_key__.]] + [[`__at_key__(s)`] [The element associated with the key + `K` in the sequence `s`; see __at__.]] +] + +[heading Models] + +* __set__ +* __map__ + +[endsect] + +[endsect] + +[section Containers] + +Fusion provides a few predefined sequences out of the box. These +/containers/ actually hold heterogenously typed data; unlike +__views__. These containers are more or less counterparts of those in __stl__. + +[heading Header] + + #include + +[section vector] + +[heading Description] + +`vector` is a __random_access_sequence__ of heterogenous typed +data structured as a simple `struct` where each element is held +as a member variable. `vector` is the simplest of the Fusion +sequence container, and in many cases the most efficient. + +[heading Header] + + #include + #include + + // numbered forms + #include + #include + #include + #include + #include + +[heading Synopsis] + +[*Numbered forms] + + template <> + struct vector0; + + template + struct vector1; + + template + struct vector2; + + template + struct vector3; + + ... + + template + struct vectorN; + +[*Variadic form] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct vector; + +The numbered form accepts the exact number of elements. Example: + + vector3 + +The variadic form accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where +`FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that +defaults to `10`. Example: + + vector + +You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before +including any Fusion header to change the default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T0`...`TN`] [Element types] [['unspecified]]] +] + +[heading Model of] + +* __random_access_sequence__ + +[variablelist Notation + [[`v`] [Instance of `vector`]] + [[`V`] [A `vector` type]] + [[`e0`...`en`] [Heterogeneous values]] + [[`s`] [A __forward_sequence__]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __random_access_sequence__. + +[table + [[Expression] [Semantics]] + [[`V()`] [Creates a vector with default constructed elements.]] + [[`V(e0, e1,... en)`] [Creates a vector with elements `e0`...`en`.]] + [[`V(s)`] [Copy constructs a vector from a __forward_sequence__, `s`.]] + [[`v = s`] [Assigns to a vector, `v`, from a __forward_sequence__, `s`.]] +] + +[heading Example] + + vector v(12, 5.5f); + std::cout << __at_c__<0>(v) << std::endl; + std::cout << __at_c__<1>(v) << std::endl; + +[endsect] + +[section cons] + +[heading Description] + +`cons` is a simple __forward_sequence__. It is a lisp style recursive list +structure where `car` is the /head/ and `cdr` is the /tail/: usually +another cons structure or `nil`: the empty list. Fusion's __list__ is built +on top of this more primitive data structure. It is more efficient than +__vector__ when the target sequence is constructed piecemeal (a data at a +time). The runtime cost of access to each element is peculiarly constant +(see __recursive_inline__). + +[heading Header] + + #include + +[heading Synopsis] + + template + struct cons; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Car`] [Head type] []] + [[`Cdr`] [Tail type] [`nil`]] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`nil`] [An empty `cons`]] + [[`C`] [A `cons` type]] + [[`l`, `l2`] [Instances of `cons`]] + [[`car`] [An arbitrary data]] + [[`cdr`] [Another `cons` list]] + [[`s`] [A __forward_sequence__]] + [[`N`] [An Integral Constant]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`nil()`] [Creates an empty list.]] + [[`C()`] [Creates a cons with default constructed elements.]] + [[`C(car)`] [Creates a cons with `car` head and default constructed tail.]] + [[`C(car, cdr)`] [Creates a cons with `car` head and `cdr` tail.]] + [[`C(s)`] [Copy constructs a cons from a __forward_sequence__, `s`.]] + [[`l = s`] [Assigns to a cons, `l`, from a __forward_sequence__, `s`.]] + [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] +] + +[blurb __note__ `__at__(l)` is provided for convenience and compatibility +with the original __tuple__ library, despite `cons` being a +__forward_sequence__ only (`at` is supposed to be a +__random_access_sequence__ requirement). The runtime complexity of __at__ is +constant (see __recursive_inline__).] + +[heading Example] + + cons > l(12, cons(5.5f)); + std::cout << __at__<0>(l) << std::endl; + std::cout << __at__<1>(l) << std::endl; + +[endsect] + +[section list] + +[heading Description] + +`list` is a __forward_sequence__ of heterogenous typed data built on top of +__cons__. It is more efficient than __vector__ when the target sequence is +constructed piecemeal (a data at a time). The runtime cost of access to +each element is peculiarly constant (see __recursive_inline__). + +[heading Header] + + #include + #include + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct list; + +The variadic class interface accepts `0` to `FUSION_MAX_LIST_SIZE` +elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined +maximum that defaults to `10`. Example: + + list + +You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before +including any Fusion header to change the default. Example: + + #define FUSION_MAX_LIST_SIZE 20 + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T0`...`TN`] [Element types] [['unspecified-type]]] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`L`] [A `list` type]] + [[`l`] [An instance of `list`]] + [[`e0`...`en`] [Heterogeneous values]] + [[`s`] [A __forward_sequence__]] + [[`N`] [An Integral Constant]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`L()`] [Creates a list with default constructed elements.]] + [[`L(e0, e1,... en)`] [Creates a list with elements `e0`...`en`.]] + [[`L(s)`] [Copy constructs a list from a __forward_sequence__, `s`.]] + [[`l = s`] [Assigns to a list, `l`, from a __forward_sequence__, `s`.]] + [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] +] + +[blurb __note__ `__at__(l)` is provided for convenience and compatibility +with the original __tuple__ library, despite `list` being a +__forward_sequence__ only (__at__ is supposed to be a +__random_access_sequence__ requirement). The runtime complexity of __at__ is +constant (see __recursive_inline__).] + +[heading Example] + + list l(12, 5.5f); + std::cout << __at__<0>(l) << std::endl; + std::cout << __at__<1>(l) << std::endl; + +[endsect] + +[section set] + +[heading Description] + +set is an __associative_sequence__ of heteregenous typed data elements. +Type identity is used to impose an equivalence relation on keys. The +element's type is its key. A set may contain at most one element for each +key. Membership testing and element key lookup has constant runtime +complexity (see __overloaded_functions__). + +[heading Header] + + #include + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct set; + +The variadic class interface accepts `0` to `FUSION_MAX_SET_SIZE` elements, +where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that +defaults to `10`. Example: + + set + +You may define the preprocessor constant `FUSION_MAX_SET_SIZE` before +including any Fusion header to change the default. Example: + + #define FUSION_MAX_SET_SIZE 20 + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T0`...`TN`] [Element types] [['unspecified-type]]] +] + +[heading Model of] + +* __associative_sequence__ +* __forward_sequence__ + +[variablelist Notation + [[`S`] [A `set` type]] + [[`s`] [An instance of `set`]] + [[`e0`...`en`] [Heterogeneous values]] + [[`fs`] [A __forward_sequence__]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __random_access_sequence__ and __associative_sequence__. + +[table + [[Expression] [Semantics]] + [[`S()`] [Creates a set with default constructed elements.]] + [[`S(e0, e1,... en)`] [Creates a set with elements `e0`...`en`.]] + [[`S(fs)`] [Copy constructs a set from a __forward_sequence__ `fs`.]] + [[`s = fs`] [Assigns to a set, `s`, from a __forward_sequence__ `fs`.]] +] + +[heading Example] + + typedef set S; + S s(12, 5.5f); + std::cout << __at_key__(s) << std::endl; + std::cout << __at_key__(s) << std::endl; + std::cout << __result_of_has_key__::value << std::endl; + +[endsect] + +[section map] + +[heading Description] + +map is an __associative_sequence__ of heteregenous typed data elements. +Each element is a key/data pair (see __fusion_pair__) where the key has no +data (type only). Type identity is used to impose an equivalence relation +on keys. A map may contain at most one element for each key. Membership +testing and element key lookup has constant runtime complexity (see +__overloaded_functions__). + +[heading Header] + + #include + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct map; + +The variadic class interface accepts `0` to `FUSION_MAX_MAP_SIZE` elements, +where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that +defaults to `10`. Example: + + map<__pair__, __pair__, __pair__ > + +You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before +including any Fusion header to change the default. Example: + + #define FUSION_MAX_MAP_SIZE 20 + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T0`...`TN`] [Element types] [['unspecified-type]]] +] + +[heading Model of] + +* __associative_sequence__ +* __forward_sequence__ + +[variablelist Notation + [[`M`] [A `map` type]] + [[`m`] [An instance of `map`]] + [[`e0`...`en`] [Heterogeneous key/value pairs (see __fusion_pair__)]] + [[`s`] [A __forward_sequence__]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __random_access_sequence__ and __associative_sequence__. + +[table + [[Expression] [Semantics]] + [[`M()`] [Creates a map with default constructed elements.]] + [[`M(e0, e1,... en)`] [Creates a map with element pairs `e0`...`en`.]] + [[`M(s)`] [Copy constructs a map from a __forward_sequence__ `s`.]] + [[`m = s`] [Assigns to a map, `m`, from a __forward_sequence__ `s`.]] +] + +[heading Example] + + typedef map< + __pair__ + , __pair__ > + map_type; + + map_type m( + __fusion_make_pair__('X') + , __fusion_make_pair__("Men")); + + std::cout << __at__(m) << std::endl; + std::cout << __at__(m) << std::endl; + +[endsect] + +[endsect] + +[section Views] + +Views are sequences that do not actually contain data, but instead impart +an alternative presentation over the data from one or more underlying +sequences. Views are proxies. They provide an efficient yet purely +functional way to work on potentially expensive sequence operations. Views +are inherently lazy. Their elements are only computed on demand only when +the elements of the underlying sequence(s) are actually accessed. Views' +lazy nature make them very cheap to copy and be passed around by value. + +[heading Header] + + #include + +[section single_view] + +`single_view` is a view into a value as a single element sequence. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct single_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T`] [Any type] []] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`S`] [A `single_view` type]] + [[`s`, `s2`] [Instances of `single_view`]] + [[`x`] [An instance of `T`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`S(x)`] [Creates a `single_view` from `x`.]] + [[`S(s)`] [Copy constructs a `single_view` from another `single_view`, `s`.]] + [[`s = s2`] [Assigns to a `single_view`, `s`, from another `single_view`, `s2`.]] +] + +[heading Example] + + single_view view(3); + std::cout << view << std::endl; + +[endsect] + +[section filter_view] + +[heading Description] + +`filter_view` is a view into a subset of its underlying sequence's elements +satisfying a given predicate (an __mpl__ metafunction). The `filter_view` +presents only those elements for which its predicate evaluates to +`mpl::true_`. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct filter_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence`] [A __forward_sequence__] []] + [[`Pred`] [Unary Metafunction + returning an `mpl::bool_`] []] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`F`] [A `filter_view` type]] + [[`f`, `f2`] [Instances of `filter_view`]] + [[`s`] [A __forward_sequence__]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`F(s)`] [Creates a `filter_view` given a sequence, `s`.]] + [[`F(f)`] [Copy constructs a `filter_view` from another `filter_view`, `f`.]] + [[`f = f2`] [Assigns to a `filter_view`, `f`, from another `filter_view`, `f2`.]] +] + +[heading Example] + + using boost::mpl::_; + using boost::mpl::not_; + using boost::is_class; + + typedef __vector__ vector_type; + + vector_type v("a-string", '@', 987654, true, 6.6); + filter_view > > view(v); + std::cout << view << std::endl; + +[endsect] + +[section iterator_range] + +[heading Description] + +`iterator_range` presents a sub-range of its underlying sequence delimited +by a pair of iterators. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct iterator_range; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`First`] [A fusion __iterator__] []] + [[`Last`] [A fusion __iterator__] []] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`IR`] [An `iterator_range` type]] + [[`f`] [An instance of `First`]] + [[`l`] [An instance of `Last`]] + [[`ir`, `ir2`] [Instances of `iterator_range`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`IR(f, l)`] [Creates an `iterator_range` given iterators, `f` and `l`.]] + [[`IR(ir)`] [Copy constructs an `iterator_range` from another `iterator_range`, `ir`.]] + [[`ir = ir2`] [Assigns to a `iterator_range`, `ir`, from another `iterator_range`, `ir2`.]] +] + +[heading Example] + + char const* s = "Ruby"; + typedef __vector__ vector_type; + vector_type vec(1, 'x', 3.3, s); + + typedef __result_of_begin__::type A; + typedef __result_of_end__::type B; + typedef __result_of_next__::type C; + typedef __result_of_prior__::type D; + + C c(vec); + D d(vec); + + iterator_range range(c, d); + std::cout << range << std::endl; + +[endsect] + +[section joint_view] + +[heading Description] + +`joint_view` presents a view which is a concatenation of two sequences. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct joint_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence1`] [A __forward_sequence__] []] + [[`Sequence2`] [A __forward_sequence__] []] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`JV`] [A `joint_view` type]] + [[`s1`] [An instance of `Sequence1`]] + [[`s2`] [An instance of `Sequence2`]] + [[`jv`, `jv2`] [Instances of `joint_view`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`JV(s1, s2)`] [Creates a `joint_view` given sequences, `s1` and `s2`.]] + [[`JV(jv)`] [Copy constructs a `joint_view` from another `joint_view`, `jv`.]] + [[`jv = jv2`] [Assigns to a `joint_view`, `jv`, from another `joint_view`, `jv2`.]] +] + +[heading Example] + + __vector__ v1(3, 'x'); + __vector__ v2("hello", 123); + joint_view< + __vector__ + , __vector__ + > view(v1, v2); + std::cout << view << std::endl; + +[endsect] + +[section zip_view] + +[heading Description] + +`zip_view` presents a view which iterates over a collection of __sequence__s in parallel. A `zip_view` +is constructed from a __sequence__ of references to the component __sequence__s. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct zip_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequences`] [A __forward_sequence__ of references to other Fusion __sequence__s] []] +] + +[heading Model of] + +* __forward_sequence__ + +[variablelist Notation + [[`ZV`] [A `joint_view` type]] + [[`s`] [An instance of `Sequences`]] + [[`zv1`, `zv2`] [Instances of `ZV`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__. + +[table + [[Expression] [Semantics]] + [[`ZV(s)`] [Creates a `zip_view` given a sequence of references to the component __sequence__s.]] + [[`ZV(zv1)`] [Copy constructs a `zip_view` from another `zip_view`, `zv`.]] + [[`zv1 = zv2`] [Assigns to a `zip_view`, `zv`, from another `zip_view`, `zv2`.]] +] + +[heading Example] + typedef __vector__ vec1; + typedef __vector__ vec2; + vec1 v1(1,2); + vec2 v2('a','b'); + typedef __vector__ sequences; + std::cout << zip_view(sequences(v1, v2)) << std::endl; // ((1 a) (2 b)) + +[endsect] + +[section transform_view] + +`transform_view` presents a transformed view of its underlying sequence +given a unary __poly_func_obj__. The `transform_view` inherits the +traversal characteristics (see __traversal_concept__) of its underlying +sequence. + +[heading Header] + + #include + +[heading Synopsis] + +[*Unary Version] + + template + struct transform_view; + +[*Binary Version] + + template + struct transform_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence`] [A __forward_sequence__] []] + [[`Sequence1`] [A __forward_sequence__] []] + [[`Sequence2`] [A __forward_sequence__] []] + [[`F`] [A __poly_func_obj__] []] +] + +[heading Model of] + +* __forward_sequence__, __bidirectional_sequence__ or +__random_access_sequence__ depending on the traversal characteristics (see +__traversal_concept__) of its underlying sequence. + +[variablelist Notation + [[`TV`] [A `transform_view` type]] + [[`BTV`] [A binary `transform_view` type]] + [[`UTV`] [A unary `transform_view` type]] + [[`f`] [An instance of `F`]] + [[`s`] [An instance of `Sequence`]] + [[`s1`] [An instance of `Sequence1`]] + [[`s2`] [An instance of `Sequence2`]] + [[`tv`, `tv2`] [Instances of `transform_view`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __forward_sequence__, __bidirectional_sequence__ or +__random_access_sequence__ depending on the traversal characteristics (see +__traversal_concept__) of its underlying sequence. + +[table + [[Expression] [Semantics]] + [[`UTV(s, f)`] [Creates a unary `transform_view` given sequence, + `s` and unary __poly_func_obj__, `f`.]] + [[`BTV(s1, s2, f)`] [Creates a binary `transform_view` given sequences, `s1` and `s2` + and unary __poly_func_obj__, `f`.]] + [[`TV(tv)`] [Copy constructs a `transform_view` from another `transform_view`, `tv`.]] + [[`tv = tv2`] [Assigns to a `transform_view`, `tv`, from another `transform_view`, `tv2`.]] +] + +[heading Example] + + struct square + { + template + struct result + { + typedef T type; + }; + + template + T operator()(T x) const + { + return x * x; + } + }; + + typedef __vector__ vector_type; + vector_type vec(2, 5, 3.3); + + transform_view transform(vec, square()); + std::cout << transform << std::endl; + +[endsect] + +[section reverse_view] + +`reverse_view` presents a reversed view of underlying sequence. The first +element will be its last and the last element will be its first. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct reverse_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence`] [A __bidirectional_sequence__] []] +] + +[heading Model of] + +* __bidirectional_sequence__ + +[variablelist Notation + [[`RV`] [A `reverse_view` type]] + [[`s`] [An instance of `Sequence`]] + [[`rv`, `rv2`] [Instances of `reverse_view`]] +] + +[heading Expression Semantics] + +Semantics of an expression is defined only where it differs from, or is not +defined in __bidirectional_sequence__. + +[table + [[Expression] [Semantics]] + [[`RV(s)`] [Creates a unary `reverse_view` given sequence, `s`.]] + [[`RV(rv)`] [Copy constructs a `reverse_view` from another `reverse_view`, `rv`.]] + [[`rv = rv2`] [Assigns to a `reverse_view`, `rv`, from another `reverse_view`, `rv2`.]] +] + +[heading Example] + + typedef __vector__ vector_type; + vector_type vec(2, 5, 3.3); + + reverse_view reverse(vec); + std::cout << reverse << std::endl; + +[endsect] + +[endsect] + +[section Adapted] + +Fusion provides a couple of adapters for other sequences such as +`std::pair`, __mpl__ sequences, and `boost::array`. These adapters are +written using Fusion's non-intrusive __extension__ mechanism. If you wish +to use these sequences with fusion, simply include the necessary files and +they will be regarded as first-class, fully conforming fusion sequences +[footnote Fusion sequences may also be adapted as fully conforming __mpl__ +sequences (see __intrinsics__). That way, we can have 2-way adaptation to +and from __mpl__ and Fusion]. + +[heading Header] + + #include + +[section std::pair] + +This module provides adapters for `std::pair`. Including the module header +makes `std::pair` a fully conforming __random_access_sequence__. + +[heading Header] + + #include + +[heading Model of] + +* __random_access_sequence__ + +[heading Example] + + std::pair p(123, "Hola!!!"); + std::cout << __at_c__<0>(p) << std::endl; + std::cout << __at_c__<1>(p) << std::endl; + std::cout << p << std::endl; + +[heading See also] + +__std_pair_doc__, __tr1_tuple_pair__ + +[endsect] + +[section mpl sequence] + +This module provides adapters for __mpl__ sequences. Including the module +header makes all __mpl__ sequences fully conforming fusion sequences. + +[heading Header] + + #include + +[heading Model of] + +* __forward_sequence__ (If the __mpl__ sequence is a forward sequence.) +* __bidirectional_sequence__ (If the __mpl__ sequence is a bidirectional sequence.) +* __random_access_sequence__ (If the __mpl__ sequence is a random access sequence.) + +[heading Example] + + mpl::vector_c vec_c; + fusion::vector2 v(vec_c); + std::cout << __at_c__<0>(v) << std::endl; + std::cout << __at_c__<1>(v) << std::endl; + + v = mpl::vector_c(); + std::cout << __at_c__<0>(v) << std::endl; + std::cout << __at_c__<1>(v) << std::endl; + +[heading See also] + +__mpl__ + +[endsect] + +[section boost::array] + +This module provides adapters for `boost::array`. Including the module +header makes `boost::array` a fully conforming __random_access_sequence__. + +[heading Header] + + #include + +[heading Model of] + +* __random_access_sequence__ + +[heading Example] + + boost::array arr = {{1,2,3}}; + + std::cout << *__begin__(arr) << std::endl; + std::cout << *__next__(__begin__(arr)) << std::endl; + std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl; + std::cout << *__prior__(__end__(arr)) << std::endl; + std::cout << __at_c__<2>(arr) << std::endl; + +[heading See also] + +__boost_array_library__ + +[endsect] + +[endsect] + +[section Intrinsics] + +Intrinsics form the essential interface of Fusion __sequence__s. __stl__ +counterparts of these functions are usually implemented as member +functions. Intrinsic functions, unlike __algorithms__, are not generic +across the full __sequence__ repertoire. They need to be implemented for +each Fusion __sequence__[footnote In practice, many of intrinsic functions +have default implementations that will work in majority of cases]. + +[heading Header] + + #include + +[section Functions] + +[section begin] + +[heading Description] + +Returns an iterator pointing to the first element in the sequence. + +[heading Synopsis] + + template + typename __result_of_begin__::type + begin(Sequence& seq); + + template + typename __result_of_begin__::type + begin(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __forward_sequence__] [The sequence we wish to get an iterator from.]] +] + +[heading Expression Semantics] + + begin(seq); + +[*Return type]: __forward_iterator__ if `seq` is a __forward_sequence__ +else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__ +else, __random_access_iterator__ if `seq` is a __random_access_sequence__. + +[*Semantics]: Returns an iterator pointing to the first element in the sequence. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(__deref__(begin(v)) == 1); + +[endsect] + +[section end] + +[heading Description] + +Returns an iterator pointing to one element past the end of the sequence. + +[heading Synopsis] + + template + typename __result_of_end__::type + end(Sequence& seq); + + template + typename __result_of_end__::type + end(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __forward_sequence__] [The sequence we wish to get an iterator from.]] +] + +[heading Expression Semantics] + + end(seq); + +[*Return type]: __forward_iterator__ if `seq` is a __forward_sequence__ +else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__ +else, __random_access_iterator__ if `seq` is a __random_access_sequence__. + +[*Semantics]: Returns an iterator pointing to one element past the end of +the sequence. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(__deref__(__prior__(end(v))) == 3); + +[endsect] + +[section empty] + +[heading Description] + +Returns a type convertible to `bool` that evaluates to `true` if the +sequence is empty, else, evaluates to `false`. + +[heading Synopsis] + + template + typename __result_of_empty__::type + empty(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]] +] + +[heading Expression Semantics] + + empty(seq); + +[*Return type]: Convertible to `bool`. + +[*Semantics]: Evaluates to `true` if the sequence is empty, else, evaluates +to `false`. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(empty(v) == false); + +[endsect] + +[section front] + +[heading Description] + +Returns the first element in the sequence. + +[heading Synopsis] + + template + typename __result_of_front__::type + front(Sequence& seq); + + template + typename __result_of_front__::type + front(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]] +] + +[heading Expression Semantics] + + front(seq); + +[*Return type]: Returns a reference to the first element in the sequence +`seq` if `seq` is mutable and `e = o`, where `e` is the first element in +the sequence, is a valid expression. Else, returns a type convertable to +the first element in the sequence. + +[*Precondition]: `__empty__(seq) == false` + +[*Semantics]: Returns the first element in the sequence. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(front(v) == 1); + +[endsect] + +[section back] + +[heading Description] + +Returns the last element in the sequence. + +[heading Synopsis] + + template + typename __result_of_back__::type + back(Sequence& seq); + + template + typename __result_of_back__::type + back(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __bidirectional_sequence__] [The sequence we wish to investigate.]] +] + +[heading Expression Semantics] + + back(seq); + +[*Return type]: Returns a reference to the last element in the sequence +`seq` if `seq` is mutable and `e = o`, where `e` is the last element in the +sequence, is a valid expression. Else, returns a type convertable to the +last element in the sequence. + +[*Precondition]: `__empty__(seq) == false` + +[*Semantics]: Returns the last element in the sequence. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(back(v) == 3); + +[endsect] + +[section size] + +[heading Description] + +Returns a type convertible to `int` that evaluates the number of elements +in the sequence. + +[heading Synopsis] + + template + typename __result_of_size__::type + size(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]] +] + +[heading Expression Semantics] + + size(seq); + +[*Return type]: Convertible to `int`. + +[*Semantics]: Returns the number of elements in the sequence. + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(size(v) == 3); + +[endsect] + +[section at] + +[heading Description] + +Returns the N-th element from the beginning of the sequence. + +[heading Synopsis] + + template + typename __result_of_at__::type + at(Sequence& seq); + + template + typename __result_of_at__::type + at(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __random_access_sequence__] [The sequence we wish to investigate.]] + [[`N`] [An __mpl__ integral constant] [An index from the beginning of the + sequence.]] +] + +[heading Expression Semantics] + + at(seq); + +[*Return type]: Returns a reference to the N-th element from the beginning +of the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the N-th +element from the beginning of the sequence, is a valid expression. Else, +returns a type convertable to the N-th element from the beginning of the +sequence. + +[*Precondition]: `0 <= N::value < __size__(s)` + +[*Semantics]: Equivalent to + + __deref__(__advance__(__begin__(s))) + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(at >(v) == 2); + +[endsect] + +[section at_c] + +[heading Description] + +Returns the N-th element from the beginning of the sequence. + +[heading Synopsis] + + template + typename __result_of_at_c__::type + at_c(Sequence& seq); + + template + typename __result_of_at_c__::type + at_c(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __random_access_sequence__] [The sequence we wish to investigate.]] + [[`N`] [An integral constant] [An index from the beginning of the + sequence.]] +] + +[heading Expression Semantics] + + at_c(seq); + +[*Return type]: Returns a reference to the N-th element from the beginning +of the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the N-th +element from the beginning of the sequence, is a valid expression. Else, +returns a type convertable to the N-th element from the beginning of the +sequence. + +[*Precondition]: `0 <= N < __size__(s)` + +[*Semantics]: Equivalent to + + __deref__(__advance__(__begin__(s))) + +[heading Header] + + #include + +[heading Example] + + __vector__ v(1, 2, 3); + assert(at_c<1>(v) == 2); + +[endsect] + +[section has_key] + +[heading Description] + +Returns a type convertible to `bool` that evaluates to `true` if the +sequence contains an element associated with a Key, else, evaluates to +`false`. + +[heading Synopsis] + + template + typename __result_of_has_key__::type + has_key(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __associative_sequence__] [The sequence we wish to investigate.]] + [[`Key`] [Any type] [The queried key.]] +] + +[heading Expression Semantics] + + has_key(seq); + +[*Return type]: Convertible to `bool`. + +[*Semantics]: Evaluates to `true` if the sequence contains an element +associated with Key, else, evaluates to `false`. + +[heading Header] + + #include + +[heading Example] + + __set__ s(1, 'x', true); + assert(has_key(s) == true); + +[endsect] + +[section at_key] + +[heading Description] + +Returns the element associated with a Key from the sequence. + +[heading Synopsis] + + template + typename __result_of_at_key__::type + at_key(Sequence& seq); + + template + typename __result_of_at_key__::type + at_key(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [Model of __associative_sequence__] [The sequence we wish to investigate.]] + [[`Key`] [Any type] [The queried key.]] +] + +[heading Expression Semantics] + + at_key(seq); + +[*Return type]: Returns a reference to the element associated with Key from +the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the +element associated with Key, is a valid expression. Else, returns a type +convertable to the element associated with Key. + +[*Precondition]: `has_key(seq) == true` + +[*Semantics]: Returns the element associated with Key. + +[heading Header] + + #include + +[heading Example] + + __set__ s(1, 'x', true); + assert(at_key(s) == 'x'); + +[endsect] + +[endsect] + +[section Metafunctions] + +[section begin] + +[heading Description] +Returns the result type of __begin__. + +[heading Synopsis] + template + struct begin + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::begin::type + +[*Return type]: An iterator modelling the same traversal concept as `Seq`. + +[*Semantics]: Returns the type of an iterator to the first element of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_begin__::type it; + BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__::type, int&>)) + +[endsect] + +[section end] + +[heading Description] +Returns the result type of __end__. + +[heading Synopsis] + template + struct end + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::end::type + +[*Return type]: A model of the same traversal concept as `Seq`. + +[*Semantics]: Returns the type of an iterator one past the end of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_prior__<__result_of_end__::type>::type first; + BOOST_MPL_ASSERT((__result_of_equal_to__::type>)) + +[endsect] + +[section empty] + +[heading Description] +Returns the result type of __empty__. + +[heading Synopsis] + template + struct empty + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::empty::type + +[*Return type]: An __mpl_integral_constant__ + +[*Semantics]: Returns `mpl::true_` if `Seq` has zero elements, `mpl::false_` otherwise. + +[heading Header] + #include + +[heading Example] + typedef __vector__<> empty_vec; + typedef __vector__ vec; + + BOOST_MPL_ASSERT((__result_of_empty__)); + BOOST_MPL_ASSERT_NOT((__result_of_empty__)); + +[endsect] + +[section front] + +[heading Description] +Returns the result type of __front__. + +[heading Synopsis] + template + struct front + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::front::type + +[*Return type]: Any type + +[*Semantics]: The type returned by dereferencing an iterator to the first element in `Seq`. Equivalent to `__result_of_deref__<__result_of_begin__::type>::type`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_front__::type, int&>)); + +[endsect] + +[section back] + +[heading Description] +Returns the result type of __back__. + +[heading Synopsis] + template + struct back + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::back::type + +[*Return type]: Any type + +[*Semantics]: The type returned by dereferencing an iterator to the last element in the sequence. Equivalent to `__result_of_deref__<__result_of_prior__<__result_of_end__::type>::type>::type`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_back__::type, char&>)); + +[endsect] + +[section size] + +[heading Description] +Returns the result type of __size__. + +[heading Synopsis] + template + struct size + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] +] + +[heading Expression Semantics] + result_of::size::type + +[*Return type]: An __mpl_integral_constant__. + +[*Semantics]: Returns the number of elements in `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + typedef __result_of_size__::type size_mpl_integral_constant; + BOOST_MPL_ASSERT_RELATION(size_mpl_integral_constant::value, ==, 3); + +[endsect] + +[section at] + +[heading Description] + +Returns the result type of __at__[footnote __result_of_at__ reflects the +actual return type of the function __at__. __sequence__s typically return +references to its elements via the __at__ function. If you want to get +the actual element type, use __result_of_value_at__]. + +[heading Synopsis] + template< + typename Seq, + typename N> + struct at + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`N`][An __mpl_integral_constant__][Index of element]] +] + +[heading Expression Semantics] + result_of::at::type + +[*Return type]: Any type. + +[*Semantics]: Returns the result type of using __at__ to access the `N`th element of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_at__ >::type, float&>)); + +[endsect] + +[section at_c] + +[heading Description] + +Returns the result type of __at_c__[footnote __result_of_at_c__ reflects +the actual return type of the function __at_c__. __sequence__s typically +return references to its elements via the __at_c__ function. If you want to +get the actual element type, use __result_of_value_at_c__]. + +[heading Synopsis] + template< + typename Seq, + int M> + struct at_c + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`M`][Positive integer index][Index of element]] +] + +[heading Expression Semantics] + result_of::at_c::type + +[*Return type]: Any type + +[*Semantics]: Returns the result type of using __at_c__ to access the `M`th element of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_at_c__::type, float&>)); + +[endsect] + +[section value_at] + +[heading Description] + +Returns the actual type at a given index from the __sequence__. + +[heading Synopsis] + template< + typename Seq, + typename N> + struct value_at + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`N`][An __mpl_integral_constant__][Index of element]] +] + +[heading Expression Semantics] + result_of::value_at::type + +[*Return type]: Any type. + +[*Semantics]: Returns the actual type at the `N`th element of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at__ >::type, float>)); + +[endsect] + +[section value_at_c] + +[heading Description] + +Returns the actual type at a given index from the __sequence__. + +[heading Synopsis] + template< + typename Seq, + int M> + struct value_at_c + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`M`][Positive integer index][Index of element]] +] + +[heading Expression Semantics] + result_of::value_at_c::type + +[*Return type]: Any type + +[*Semantics]: Returns the actual type at the `M`th element of `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __vector__ vec; + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at_c__::type, float>)); + +[endsect] + +[section has_key] + +[heading Description] +Returns the result type of __has_key__. + +[heading Synopsis] + template< + typename Seq, + typename Key> + struct has_key + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`Key`][Any type][Key type]] +] + +[heading Expression Semantics] + result_of::has_key::type + +[*Return type]: An __mpl_integral_constant__. + +[*Semantics]: Returns `mpl::true_` if `Seq` contains an element with key type `Key`, returns `mpl::false_` otherwise. + +[heading Header] + #include + +[heading Example] + typedef __map__<__pair__, __pair__, __pair__ > mymap; + BOOST_MPL_ASSERT((__result_of_has_key__)); + BOOST_MPL_ASSERT_NOT((__result_of_has_key__)); + +[endsect] + +[section at_key] + +[heading Description] + +Returns the result type of __at_key__[footnote __result_of_at_key__ +reflects the actual return type of the function __at_key__. __sequence__s +typically return references to its elements via the __at_key__ function. If +you want to get the actual element type, use __result_of_value_at_key__]. + +[heading Synopsis] + template< + typename Seq, + typename Key> + struct at_key + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`Key`][Any type][Key type]] +] + +[heading Expression Semantics] + result_of::at_key::type + +[*Return type]: Any type. + +[*Semantics]: Returns the result of using __at_key__ to access the element with key type `Key` in `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __map__<__pair__, __pair__, __pair__ > mymap; + BOOST_MPL_ASSERT((boost::is_same<__result_of_at_key__::type, char&>)); + +[endsect] + +[section value_at_key] + +[heading Description] +Returns the actual element type associated with a Key from the __sequence__. + +[heading Synopsis] + template< + typename Seq, + typename Key> + struct value_at_key + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq`][A model of __forward_sequence__][Argument sequence]] + [[`Key`][Any type][Key type]] +] + +[heading Expression Semantics] + result_of::value_at_key::type + +[*Return type]: Any type. + +[*Semantics]: Returns the actual element type associated with key type +`Key` in `Seq`. + +[heading Header] + #include + +[heading Example] + typedef __map__<__pair__, __pair__, __pair__ > mymap; + BOOST_MPL_ASSERT((boost::is_same<__result_of_at_key__::type, char>)); + +[endsect] + +[endsect] + +[endsect] + +[section Generation] + +These are the functions that you can use to generate various forms of +__containers__ from elemental values. + +[heading Header] + + #include + +[section Functions] + +[section make_list] + +[heading Description] + +Create a __list__ from one or more values. + +[heading Synopsis] + + template + typename __result_of_make_list__::type + make_list(T0 const& x0, T1 const& x1... TN const& xN); + +The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where +`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults +to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` +before including any Fusion header to change the default. Example: + + #define FUSION_MAX_LIST_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_list`]] +] + +[heading Expression Semantics] + + make_list(x0, x1,... xN); + +[*Return type]: __result_of_make_list__`::type` + +[*Semantics]: Create a __list__ from `x0, x1,... xN`. + +[heading Header] + + #include + +[heading Example] + + make_list(123, "hello", 12.5) + +[heading See also] + +__note_boost_ref__ + +[endsect] + +[section make_cons] + +[heading Description] + +Create a __cons__ from `car` (/head/) and optional `cdr` (/tail/). + +[heading Synopsis] + + template + typename __result_of_make_cons__::type + make_cons(Car const& car); + + template + typename __result_of_make_cons__::type + make_cons(Car const& car, Cdr const& cdr); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`car`] [Instance of `Car`] [The list's head]] + [[`cdr`] [Instance of `Cdr`] [The list's tail (optional)]] +] + +[heading Expression Semantics] + + make_cons(car, cdr); + +[*Return type]: __result_of_make_cons__`::type` or +__result_of_make_cons__`::type` + +[*Semantics]: Create a __cons__ from `car` (/head/) and optional `cdr` (/tail/). + +[heading Header] + + #include + +[heading Example] + + make_cons('x', make_cons(123)) + +[heading See also] + +__note_boost_ref__ + +[endsect] + +[section make_vector] + +[heading Description] + +Create a __vector__ from one or more values. + +[heading Synopsis] + + template + typename __result_of_make_vector__::type + make_vector(T0 const& x0, T1 const& x1... TN const& xN); + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, +where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that +defaults to `10`. You may define the preprocessor constant +`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the +default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_vector`]] +] + +[heading Expression Semantics] + + make_vector(x0, x1,... xN); + +[*Return type]: __result_of_make_vector__`::type` + +[*Semantics]: Create a __vector__ from `x0, x1,... xN`. + +[heading Header] + + #include + +[heading Example] + + make_vector(123, "hello", 12.5) + +[heading See also] + +__note_boost_ref__ + +[endsect] + +[section make_set] + +[heading Description] + +Create a __set__ from one or more values. + +[heading Synopsis] + + template + typename __result_of_make_set__::type + make_set(T0 const& x0, T1 const& x1... TN const& xN); + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE`[footnote +`set` is implemented in terms of the vector. That is why we reuse +`FUSION_MAX_VECTOR_SIZE`] elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_set`]] +] + +[heading Expression Semantics] + + make_set(x0, x1,... xN); + +[*Return type]: __result_of_make_set__`::type` + +[*Semantics]: Create a __set__ from `x0, x1,... xN`. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + make_set(123, "hello", 12.5) + +[heading See also] + +__note_boost_ref__ + +[endsect] + +[section make_map] + +[heading Description] + +Create a __map__ from one or more key/data pairs. + +[heading Synopsis] + + template < + typename K0, typename K1,... typename KN + , typename T0, typename T1,... typename TN> + typename __result_of_make_map__::type + make_map(T0 const& x0, T1 const& x1... TN const& xN); + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE`[footnote +`map` is implemented in terms of the vector. That is why we reuse +`FUSION_MAX_VECTOR_SIZE`] elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`K0, K1,... KN`] [The key types] [Keys associated with `x0, x1,... xN`]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_map`]] +] + +[heading Expression Semantics] + + make_map(x0, x1,... xN); + +[*Return type]: __result_of_make_map__`::type` + +[*Semantics]: Create a __map__ from `K0, K1,... KN` keys and +`x0, x1,... xN` data. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + make_map( + __fusion_make_pair__('X') + , __fusion_make_pair__("Men")) + +[heading See also] + +__note_boost_ref__, __fusion_pair__ + +[endsect] + +[section Tiers] + +Tiers are sequences, where all elements are non-const reference types. They +are constructed with a call to a couple of /tie/ function templates. The +succeeding sections document the various /tier/ flavors. + +* __list_tie__ +* __vector_tie__ + +Example: + + int i; char c; double d; + ... + __vector_tie__(i, c, a); + +The __vector_tie__ function creates a __vector__ of type +`__vector__`. The same result could be achieved with the call +__make_vector__(__boost_ref_call__(i), __boost_ref_call__(c), __boost_ref_call__(a)) +[footnote see __boost_ref__ for details about `ref`]. + +A /tie/ can be used to 'unpack' another tuple into variables. E.g.: + + int i; char c; double d; + __vector_tie__(i, c, d) = __make_vector__(1,'a', 5.5); + std::cout << i << " " << c << " " << d; + +This code prints 1 a 5.5 to the standard output stream. A sequence +unpacking operation like this is found for example in ML and Python. It is +convenient when calling functions which return sequences. + +[heading Ignore] + +There is also an object called /ignore/ which allows you to ignore an +element assigned by a sequence. The idea is that a function may return a +sequence, only part of which you are interested in. For example: + + char c; + __vector_tie__(ignore, c) = __make_vector__(1, 'a'); + +[endsect] + +[section list_tie] + +[heading Description] + +Constructs a tie using a __list__ sequence. + +[heading Synopsis] + + template + __list__ + list_tie(T0& x0, T1& x1... TN& xN); + +The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where +`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults +to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` +before including any Fusion header to change the default. Example: + + #define FUSION_MAX_LIST_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `list_tie`]] +] + +[heading Expression Semantics] + + list_tie(x0, x1,... xN); + +[*Return type]: __list__ + +[*Semantics]: Create a __list__ of references from `x0, x1,... xN`. + +[heading Header] + + #include + +[heading Example] + + int i = 123; + double d = 123.456; + list_tie(i, d) + +[endsect] + +[section vector_tie] + +[heading Description] + +Constructs a tie using a __vector__ sequence. + +[heading Synopsis] + + template + __vector__ + vector_tie(T0& x0, T1& x1... TN& xN); + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, +where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that +defaults to `10`. You may define the preprocessor constant +`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the +default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `vector_tie`]] +] + +[heading Expression Semantics] + + vector_tie(x0, x1,... xN); + +[*Return type]: __vector__ + +[*Semantics]: Create a __vector__ of references from `x0, x1,... xN`. + +[heading Header] + + #include + +[heading Example] + + int i = 123; + double d = 123.456; + vector_tie(i, d) + +[endsect] + +[endsect] + +[section MetaFunctions] + +[section make_list] + +[heading Description] + +Returns the result type of __make_list__. + +[heading Synopsis] + + template + struct make_list; + +The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where +`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults +to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` +before including any Fusion header to change the default. Example: + + #define FUSION_MAX_LIST_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T0, T1,... TN`] [Any type] [Template arguments to `make_list`]] +] + +[heading Expression Semantics] + + result_of::make_list::type + +[*Return type]: A __list__ with elements of types converted following the +rules for __element_conversion__. + +[*Semantics]: Create a __list__ from `T0, T1,... TN`. + +[heading Header] + + #include + +[heading Example] + + result_of::make_list::type + +[endsect] + +[section make_cons] + +[heading Description] + +Returns the result type of __make_cons__. + +[heading Synopsis] + + template + struct make_cons; + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`Car`] [Any type] [The list's head type]] + [[`Cdr`] [A `cons`] [The list's tail type (optional)]] +] + +[heading Expression Semantics] + + result_of::make_cons::type + +[*Return type]: A __cons__ with head element, `Car`, of type converted +following the rules for __element_conversion__, and tail, `Cdr`. + +[*Semantics]: Create a __cons__ from `Car` (/head/) and optional `Cdr` (/tail/). + +[heading Header] + + #include + +[heading Example] + + result_of::make_cons::type>::type + +[endsect] + +[section make_vector] + +[heading Description] + +Returns the result type of __make_vector__. + +[heading Synopsis] + + template + struct make_vector; + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, +where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that +defaults to `10`. You may define the preprocessor constant +`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the +default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T0, T1,... TN`] [Any type] [Template arguments to `make_vector`]] +] + +[heading Expression Semantics] + + result_of::make_vector::type + +[*Return type]: A __vector__ with elements of types converted following the +rules for __element_conversion__. + +[*Semantics]: Create a __vector__ from `T0, T1,... TN`. + +[heading Header] + + #include + +[heading Example] + + result_of::make_vector::type + +[endsect] + +[section make_set] + +[heading Description] + +Returns the result type of __make_set__. + +[heading Synopsis] + + template + struct make_set; + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE`[footnote +`set` is implemented in terms of the vector. That is why we reuse +`FUSION_MAX_VECTOR_SIZE`] elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T0, T1,... TN`] [Any type] [The arguments to `make_set`]] +] + +[heading Expression Semantics] + + result_of::make_set::type + +[*Return type]: A __set__ with elements of types converted following the +rules for __element_conversion__. + +[*Semantics]: Create a __set__ from `T0, T1,... TN`. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + result_of::make_set::type + +[endsect] + +[section make_map] + +[heading Description] + +Returns the result type of __make_map__. + +[heading Synopsis] + + template < + typename K0, typename K1,... typename KN + , typename T0, typename T1,... typename TN> + struct make_map; + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE`[footnote +`map` is implemented in terms of the vector. That is why we reuse +`FUSION_MAX_VECTOR_SIZE`] elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`K0, K1,... KN`] [Any type] [Keys associated with `T0, T1,... TN`]] + [[`T0, T1,... TN`] [Any type] [Data associated with keys `K0, K1,... KN`]] +] + +[heading Expression Semantics] + + resulf_of::make_map::type; + +[*Return type]: __result_of_make_map__`::type` + +[*Semantics]: A __map__ with __fusion_pair__ elements where the +`second_type` is converted following the rules for __element_conversion__. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + result_of::make_map::type + +[heading See also] + +__fusion_pair__ + +[endsect] + +[section list_tie] + +[heading Description] + +Returns the result type of __list_tie__. + +[heading Synopsis] + + template + struct list_tie; + +The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where +`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults +to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` +before including any Fusion header to change the default. Example: + + #define FUSION_MAX_LIST_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T0, T1,... TN`] [Any type] [The arguments to `list_tie`]] +] + +[heading Expression Semantics] + + result_of::list_tie::type; + +[*Return type]: __list__ + +[*Semantics]: Create a __list__ of references from `T0, T1,... TN`. + +[heading Header] + + #include + +[heading Example] + + result_of::list_tie::type + +[endsect] + +[section vector_tie] + +[heading Description] + +Returns the result type of __vector_tie__. + +[heading Synopsis] + + template + struct vector_tie; + +The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, +where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that +defaults to `10`. You may define the preprocessor constant +`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the +default. Example: + + #define FUSION_MAX_VECTOR_SIZE 20 + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T0, T1,... TN`] [Any type] [The arguments to `vector_tie`]] +] + +[heading Expression Semantics] + + result_of::vector_tie::type; + +[*Return type]: __vector__ + +[*Semantics]: Create a __vector__ of references from `T0, T1,... TN`. + +[heading Header] + + #include + +[heading Example] + + result_of::vector_tie::type + +[endsect] + +[endsect] + +[endsect] + +[section Conversion] + +All fusion sequences can be converted to one of the __containers__ types +using one of these conversion functions. + +[heading Header] + + #include + +[section Functions] + +[section as_list] + +[heading Description] + +Convert a fusion sequence to a __list__. + +[heading Synopsis] + + template + typename result_of::as_list::type + as_list(Sequence& seq); + + template + typename result_of::as_list::type + as_list(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [An instance of Sequence] [The sequence to convert.]] +] + +[heading Expression Semantics] + + as_list(seq); + +[*Return type]: __result_of_as_list__`::type` + +[*Semantics]: Convert a fusion sequence, `seq`, to a __list__. + +[heading Header] + + #include + +[heading Example] + + as_list(__make_vector__('x', 123, "hello")) + +[endsect] + +[section as_vector] + +[heading Description] + +Convert a fusion sequence to a __vector__. + +[heading Synopsis] + + template + typename result_of::as_vector::type + as_vector(Sequence& seq); + + template + typename result_of::as_vector::type + as_vector(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [An instance of Sequence] [The sequence to convert.]] +] + +[heading Expression Semantics] + + as_vector(seq); + +[*Return type]: __result_of_as_vector__`::type` + +[*Semantics]: Convert a fusion sequence, `seq`, to a __vector__. + +[heading Header] + + #include + +[heading Example] + + as_vector(__make_list__('x', 123, "hello")) + +[endsect] + +[section as_set] + +[heading Description] + +Convert a fusion sequence to a __set__. + +[heading Synopsis] + + template + typename result_of::as_set::type + as_set(Sequence& seq); + + template + typename result_of::as_set::type + as_set(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [An instance of Sequence] [The sequence to convert.]] +] + +[heading Expression Semantics] + + as_set(seq); + +[*Return type]: __result_of_as_set__`::type` + +[*Semantics]: Convert a fusion sequence, `seq`, to a __set__. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + as_set(__make_vector__('x', 123, "hello")) + +[endsect] + +[section as_map] + +[heading Description] + +Convert a fusion sequence to a __map__. + +[heading Synopsis] + + template + typename result_of::as_map::type + as_map(Sequence& seq); + + template + typename result_of::as_map::type + as_map(Sequence const& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`seq`] [An instance of Sequence] [The sequence to convert.]] +] + +[heading Expression Semantics] + + as_map(seq); + +[*Return type]: __result_of_as_map__`::type` + +[*Semantics]: Convert a fusion sequence, `seq`, to a __map__. + +[*Precondition]: The elements of the sequence are assumed to be +__fusion_pair__s. There may be no duplicate __fusion_pair__ key types. + +[heading Header] + + #include + +[heading Example] + + as_map(__make_vector__( + __fusion_make_pair__('X') + , __fusion_make_pair__("Men"))) + +[endsect] + +[endsect] + +[section Metafunctions] + +[section as_list] + +[heading Description] + +Returns the result type of __as_list__. + +[heading Synopsis] + + template + struct as_list; + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A fusion __sequence__] [The sequence type to convert.]] +] + +[heading Expression Semantics] + + result_of::as_list::type; + +[*Return type]: A __list__ with same elements as the input sequence, +`Sequence`. + +[*Semantics]: Convert a fusion sequence, `Sequence`, to a __list__. + +[heading Header] + + #include + +[heading Example] + + result_of::as_list<__vector__ >::type + +[endsect] + +[section as_vector] + +[heading Description] + +Returns the result type of __as_vector__. + +[heading Synopsis] + + template + struct as_vector; + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] +] + +[heading Expression Semantics] + + result_of::as_vector::type; + +[*Return type]: A __vector__ with same elements as the input sequence, +`Sequence`. + +[*Semantics]: Convert a fusion sequence, `Sequence`, to a __vector__. + +[heading Header] + + #include + +[heading Example] + + result_of::as_vector<__list__ >::type + +[endsect] + +[section as_set] + +[heading Description] + +Returns the result type of __as_set__. + +[heading Synopsis] + + template + struct as_set; + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] +] + +[heading Expression Semantics] + + result_of::as_set::type; + +[*Return type]: A __set__ with same elements as the input sequence, +`Sequence`. + +[*Semantics]: Convert a fusion sequence, `Sequence`, to a __set__. + +[*Precondition]: There may be no duplicate key types. + +[heading Header] + + #include + +[heading Example] + + result_of::as_set<__vector__ >::type + +[endsect] + +[section as_map] + +[heading Description] + +Returns the result type of __as_map__. + +[heading Synopsis] + + template + struct as_map; + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] +] + +[heading Expression Semantics] + + result_of::as_map::type; + +[*Return type]: A __map__ with same elements as the input sequence, +`Sequence`. + +[*Semantics]: Convert a fusion sequence, `Sequence`, to a __map__. + +[*Precondition]: The elements of the sequence are assumed to be +__fusion_pair__s. There may be no duplicate __fusion_pair__ key types. + +[heading Header] + + #include + +[heading Example] + + result_of::as_map<__vector__< + __fusion_pair__ + , __fusion_pair__ > >::type + +[endsect] + +[endsect] + +[endsect] + +[section Operators] + +These operators, like the __algorithms__, work generically on all Fusion +sequences. All conforming Fusion sequences automatically get these +operators for free. + +[section I/O] + +The I/O operators: `<<` and `>>` work generically on all Fusion sequences. +The global `operator<<` has been overloaded for generic output streams such +that __sequence__s are output by recursively calling `operator<<` for each +element. Analogously, the global `operator>>` has been overloaded to +extract __sequence__s from generic input streams by recursively calling +`operator>>` for each element. + +The default delimiter between the elements is space, and the __sequence__ +is enclosed in parenthesis. For Example: + + __vector__ a(1.0f, 2, std::string("Howdy folks!"); + cout << a; + +outputs the __vector__ as: (1.0 2 Howdy folks!) + +The library defines three manipulators for changing the default behavior: + +[variablelist Manipulators + [[`tuple_open(arg)`] [Defines the character that is output before the first element.]] + [[`tuple_close(arg)`] [Defines the character that is output after the last element.]] + [[`tuple_delimiter(arg)`] [Defines the delimiter character between elements.]] +] + +The argument to `tuple_open`, `tuple_close` and `tuple_delimiter` may be a +`char`, `wchar_t`, a C-string, or a wide C-string. + +Example: + + std::cout << tuple_open('[') << tuple_close(']') << tuple_delimiter(", ") << a; + +outputs the same __vector__, `a` as: [1.0, 2, Howdy folks!] + +The same manipulators work with `operator>>` and `istream` as well. Suppose +the `std::cin` stream contains the following data: + + (1 2 3) [4:5] + +The code: + + __vector__ i; + __vector__ j; + + std::cin >> i; + std::cin >> set_open('[') >> set_close(']') >> set_delimiter(':'); + std::cin >> j; + +reads the data into the __vector__s `i` and `j`. + +Note that extracting __sequence__s with `std::string` or C-style string +elements does not generally work, since the streamed __sequence__ +representation may not be unambiguously parseable. + +[heading Header] + + #include + +[section in] + +[heading Description] + +Read a __sequence__ from an input stream. + +[heading Synopsis] + + template + IStream& + operator>>(IStream& is, Sequence& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[is] [An input stream.] [Stream to extract information from.]] + [[seq] [A __sequence__.] [The sequence to read.]] +] + +[heading Expression Semantics] + + is >> seq + +[*Return type]: IStream& + +[*Semantics]: For each element, `e`, in sequence, `seq`, call `is >> e`. + +[heading Header] + + #include + +[heading Example] + + __vector__ v; + std::cin >> v; + +[endsect] + +[section out] + +[heading Description] + +Write a __sequence__ to an output stream. + +[heading Synopsis] + + template + OStream& + operator<<(OStream& os, Sequence& seq); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[os] [An output stream.] [Stream to write information to.]] + [[seq] [A __sequence__.] [The sequence to write.]] +] + +[heading Expression Semantics] + + os << seq + +[*Return type]: OStream& + +[*Semantics]: For each element, `e`, in sequence, `seq`, call `os << e`. + +[heading Header] + + #include + +[heading Example] + + std::cout << __make_vector__(123, "Hello", 'x') << std::endl; + +[endsect] + +[endsect] + +[section Comparison] + +The Comparison operators: `==`, `!=`, `<`, `<=`, `>=` and `>=` work +generically on all Fusion sequences. Comparison operators are "short- +circuited": elementary comparisons start from the first elements and are +performed only until the result is clear. + +[heading Header] + + #include + +[section equal] + +[heading Description] + +Compare two sequences for equality. + +[heading Synopsis] + + template + bool + operator==(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a == b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a == b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__s, +e and f, e == f returns true. + +[heading Header] + + #include + +[heading Example] + + __vector__ v1(5, 'a'); + __vector__ v2(5, 'a'); + assert(v1 == v2); + +[endsect] + +[section not equal] + +Compare two sequences for inequality. + +[heading Synopsis] + + template + bool + operator!=(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a != b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a == b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: + +Returns !(a == b). + +[heading Header] + + #include + +[heading Example] + + __vector__ v3(5, 'b'); + __vector__ t4(2, 'a'); + assert(v1 != v3); + assert(v1 != t4); + assert(!(v1 != v2)); + +[endsect] + +[section less than] + +Lexicographically compare two sequences. + +[heading Synopsis] + + template + bool + operator<(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a < b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a < b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: Returns the lexicographical comparison of between `a` and `b`. + +[heading Header] + + #include + +[heading Example] + + __vector__ v1(4, 3.3f); + __vector__ v2(5, 3.3f); + __vector__ v3(5, 4.4); + assert(v1 < v2); + assert(v2 < v3); + +[endsect] + +[section less than equal] + +Lexicographically compare two sequences. + +[heading Synopsis] + + template + bool + operator<=(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a <= b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a < b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: Returns !(b < a). + +[heading Header] + + #include + +[heading Example] + + __vector__ v1(4, 3.3f); + __vector__ v2(5, 3.3f); + __vector__ v3(5, 4.4); + assert(v1 <= v2); + assert(v2 <= v3); + +[endsect] + +[section greater than] + +Lexicographically compare two sequences. + +[heading Synopsis] + + template + bool + operator>(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a > b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a < b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: Returns b < a. + +[heading Header] + + #include + +[heading Example] + + __vector__ v1(4, 3.3f); + __vector__ v2(5, 3.3f); + __vector__ v3(5, 4.4); + assert(v2 > v1); + assert(v3 > v2); + +[endsect] + +[section greater than equal] + +Lexicographically compare two sequences. + +[heading Synopsis] + + template + bool + operator>=(Seq1 const& a, Seq2 const& b); + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`a, b`] [Instances of __sequence__] [__sequence__s to compare]] +] + +[heading Expression Semantics] + + a >= b + +[*Return type]: `bool` + +[*Requirements]: + +For each element, `e1`, in sequence `a`, and for each element, `e2`, in +sequence `b`, `a < b` is a valid expression returning a type that is +convertible to bool. + +An attempt to compare two Sequences of different lengths results in a +compile time error. + +[*Semantics]: Returns !(a < b). + +[heading Header] + + #include + +[heading Example] + + __vector__ v1(4, 3.3f); + __vector__ v2(5, 3.3f); + __vector__ v3(5, 4.4); + assert(v2 >= v1); + assert(v3 >= v2); + +[endsect] + +[endsect] + +[endsect] + +[endsect] + diff --git a/doc/support.qbk b/doc/support.qbk new file mode 100644 index 00000000..7c04de0c --- /dev/null +++ b/doc/support.qbk @@ -0,0 +1,309 @@ +[section Support] + +A couple of classes and metafunctions provide basic support for Fusion. + +[section is_sequence] + +[heading Description] + +Metafunction that evaluates to `mpl::true_` if a certain type `T` is a +conforming Fusion __sequence__, `mpl::false_` otherwise. This may be +specialized to accomodate clients which provide Fusion conforming sequences. + +[heading Synopsis] + + namespace traits + { + template + struct is_sequence + { + typedef __unspecified__ type; + }; + } + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T`] [Any type] [The type to query.]] +] + +[heading Expression Semantics] + + typedef traits::is_sequence::type c; + +[*Return type]: An __mpl_boolean_constant__. + +[*Semantics]: Metafunction that evaluates to `mpl::true_` if a certain type +`T` is a conforming Fusion sequence, `mpl::false_` otherwise. + +[heading Header] + + #include + +[heading Example] + + BOOST_MPL_ASSERT_NOT(( traits::is_sequence< std::vector > )); + BOOST_MPL_ASSERT_NOT(( is_sequence< int > )); + BOOST_MPL_ASSERT(( traits::is_sequence<__list__<> > )); + BOOST_MPL_ASSERT(( traits::is_sequence<__list__ > )); + BOOST_MPL_ASSERT(( traits::is_sequence<__vector__<> > )); + BOOST_MPL_ASSERT(( traits::is_sequence<__vector__ > )); + +[endsect] + +[section is_view] + +[heading Description] + +Metafunction that evaluates to `mpl::true_` if a certain type `T` is a +conforming Fusion __view__, `mpl::false_` otherwise. A view is a +specialized sequence that does not actually contain data. Views hold +sequences which may be other views. In general, views are held by other +views by value, while non-views are held by other views by reference. `is_view` +may be specialized to accomodate clients providing Fusion conforming views. + +[heading Synopsis] + + namespace traits + { + template + struct is_view + { + typedef __unspecified__ type; + }; + } + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T`] [Any type] [The type to query.]] +] + +[heading Expression Semantics] + + typedef traits::is_view::type c; + +[*Return type]: An __mpl_boolean_constant__. + +[*Semantics]: Metafunction that evaluates to `mpl::true_` if a certain type +`T` is a conforming Fusion view, `mpl::false_` otherwise. + +[heading Header] + + #include + +[heading Example] + + BOOST_MPL_ASSERT_NOT(( traits::is_view > )); + BOOST_MPL_ASSERT_NOT(( traits::is_view )); + + using boost::mpl::_ + using boost::is_pointer; + typedef __vector__ vector_type; + typedef __filter_view__ > filter_view_type; + BOOST_MPL_ASSERT(( traits::is_view )); + +[endsect] + +[section tag_of] + +[heading Description] + +All conforming Fusion sequences and iterators have an associated tag type. +The purpose of the tag is to enable __tag_dispatching__ from __intrinsic__ +functions to implementations appropriate for the type. The default implementation +of `tag_of` returns `T::ftag` for a given type `T`, if such a member typedef exists. + +This metafunction may be specialized to accomodate clients providing Fusion conforming sequences. + +[heading Synopsis] + + namespace traits + { + template + struct tag_of + { + typedef __unspecified__ type; + }; + } +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T`] [Any type] [The type to query.]] +] + +[heading Expression Semantics] + + typedef traits::tag_of::type tag; + +[*Return type]: Any type. + +[*Semantics]: Returns the tag type associated with `T`. + +[heading Header] + + #include + +[heading Example] + + typedef traits::is_sequence<__list__<> tag1; + typedef traits::is_sequence<__list__ > tag2; + typedef traits::is_sequence<__vector__<> > tag3; + typedef traits::is_sequence<__vector__ > tag4; + + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + +[endsect] + +[section category_of] + +[heading Description] + +A metafunction that establishes the conceptual classification of a particular +__sequence__ or __iterator__ (see __iterator_concepts__ and +__sequence_concepts__). + +[heading Synopsis] + + namespace traits + { + template + struct category_of + { + typedef __unspecified__ type; + }; + } + +[heading Parameters] + +[table + [[Parameter] [Requirement] [Description]] + [[`T`] [Any type] [The type to query.]] +] + +[heading Expression Semantics] + + typedef traits::category_of::type category; + +[*Return type]: + +For Iterators, the return type is derived from one of: + + struct incrementable_traversal_tag {}; + + struct single_pass_traversal_tag + : incrementable_traversal_tag {}; + + struct forward_traversal_tag + : single_pass_traversal_tag {}; + + struct bidirectional_traversal_tag + : forward_traversal_tag {}; + + struct random_access_traversal_tag + : bidirectional_traversal_tag {}; + +For Sequences, the return type is derived from one of: + + struct incrementable_sequence_tag {}; + + struct single_pass_sequence_tag + : incrementable_sequence_tag {}; + + struct forward_sequence_tag + : single_pass_sequence_tag {}; + + struct bidirectional_sequence_tag + : forward_sequence_tag {}; + + struct random_access_sequence_tag + : bidirectional_sequence_tag {}; + +And optionally from: + + struct associative_sequence_tag {}; + +[*Semantics]: Establishes the conceptual classification of a particular +__sequence__ or __iterator__. + +[heading Header] + + #include + +[heading Example] + + using boost::is_base_of; + typedef traits::category_of<__list__<> >::type list_category; + typedef traits::category_of<__vector__<> >::type vector_category; + BOOST_MPL_ASSERT(( is_base_of )); + BOOST_MPL_ASSERT(( is_base_of )); + +[endsect] + +[section pair] + +[heading Description] + +Fusion `pair` type is a half runtime pair. A half runtime pair is similar +to a __std_pair__, but, unlike __std_pair__, the first type does not have data. +It is used as elements in __map__s, for example. + +[heading Synopsis] + + template + struct pair; + +[heading Template parameters] + +[table + [[Parameter] [Description]] + [[First] [The first type. This is purely a type. No data is held.]] + [[Second] [The second type. This contains data.]] +] + +[variablelist Notation + [[`P`] [Fusion pair type]] + [[`p`, `p2`] [Fusion pairs]] + [[`F`, `S`] [Arbitrary types]] + [[`s`] [Value of type `S`]] + [[`o`] [Output stream]] + [[`i`] [Input stream]] +] + +[heading Expression Semantics] + +[table + [[Expression] [Semantics]] + [[`P::first_type`] [The type of the first template parameter, `F`.]] + [[`P::second_type`] [The type of the second template parameter, `S`.]] + [[`P()`] [Default construction.]] + [[`P(s)`] [Construct a pair given value for the second type, `s`.]] + [[`P(p2)`] [Copy constructs a pair from another pair, `p2`.]] + [[`p = p2`] [Assigns a pair, p1, from another pair, `p2`.]] + [[make_pair(s)] [Make a pair given the first type, `F`, and a value for + the second type, `s`. The second type assumes the type of `s`]] + [[`o << p`] [Output `p` to output stream, `o`.]] + [[`i >> p`] [Input `p` from input stream, `i`.]] + [[`p == p2`] [Tests two pairs for equality.]] + [[`p != p2`] [Tests two pairs for inequality.]] +] + +[heading Header] + + #include + +[heading Example] + + pair p('X'); + std::cout << p << std::endl; + std::cout << make_pair('X') << std::endl; + assert((p == make_pair('X'))); + +[endsect] + +[endsect] + diff --git a/doc/tuples.qbk b/doc/tuples.qbk new file mode 100644 index 00000000..038c8180 --- /dev/null +++ b/doc/tuples.qbk @@ -0,0 +1,264 @@ +[section Tuples] +The TR1 technical report describes extensions to the C++ standard library. +Many of these extensions will be considered for the next +iteration of the C++ standard. TR1 describes a tuple type, and +support for treating `std::pair` as a type of tuple. + +Fusion provides full support for the __tr1__tuple__ interface, and the extended +uses of `std::pair` described in the TR1 document. + +[section Class template tuple] +Fusion's implementation of the __tr1__tuple__ is also a fusion __forward_sequence__. +As such the fusion tuple type provides a lot of functionality beyond that required by TR1. + +Currently tuple is basically a synonym for __vector__, although this may be changed +in future releases of fusion. + +[heading Synopsis] + template< + typename T1 = __unspecified__, + typename T2 = __unspecified__, + ... + typename TN = __unspecified__> + class tuple; + +[heading Header] + #include + +[section Construction] + +[heading Description] +The __tr1__tuple__ type provides a default constructor, a constructor that takes initializers for all of its elements, a copy constructor, and a converting copy constructor. The details of the various constructors are described in this section. + +[heading Specification] + +[variablelist Notation + [[`T1 ... TN`, `U1 ... UN`][Tuple element types]] + [[`P1 ... PN`] [Parameter types]] + [[`Ti`, `Ui`] [The type of the `i`th element of a tuple]] + [[`Pi`] [The type of the `i`th parameter]] +] + + tuple(); + +[*Requirements]: Each `Ti` is default constructable. + +[*Semantics]: Default initializes each element of the tuple. + + tuple(P1,P2,...,PN); + +[*Requirements]: Each `Pi` is `Ti` if `Ti` is a reference type, `const Ti&` otherwise. + +[*Semantics]: Copy initializes each element with the corresponding parameter. + + tuple(const tuple& t); + +[*Requirements]: Each `Ti` should be copy constructable. + +[*Semantics]: Copy constructs each element of `*this` with the corresponding element of `t`. + + template + tuple(const tuple& t); + +[*Requirements]: Each `Ti` shall be constructible from the corresponding `Ui`. + +[*Semantics]: Constructs each element of `*this` with the corresponding element of `t`. + +[endsect] + +[section Tuple creation functions] + +[heading Description] +TR1 describes 2 utility functions for creating __tr1__tuple__s. `make_tuple` builds a tuple out of it's argument list, and `tie` builds a tuple of references to it's arguments. The details of these creation functions are described in this section. + +[heading Specification] + + template + tuple make_tuple(const T1& t1, const T2& t2, ..., const TN& tn); + +Where `Vi` is `X&` if the cv-unqualified type `Ti` is `reference_wrapper`, otherwise `Vi` is `Ti`. + +[*Returns]: `tuple(t1, t2, ..., tN)` + + template + tuple tie(T1& t1, T2& t2, ..., TN& tn); + +[*Returns]: tuple(t1, t2, ..., tN). When argument `ti` is `ignore`, assigning any value to the corresponding tuple element has has no effect. + +[endsect] + +[section Tuple helper classes] + +[heading Description] +The __tr1__tuple__ provides 2 helper traits, for compile time access to the tuple size, and the element types. + +[heading Specification] + + tuple_size::value + +[*Requires]: `T` is any fusion sequence type, including `tuple`. + +[*Type]: __mpl_integral_constant__ + +[*Value]: The number of elements in the sequence. Equivalent to `__result_of_size__::type`. + + tuple_element::type + +[*Requires]: `T` is any fusion sequence type, including `tuple`. `0 <= I < N` or the program is ill formed. + +[*Value]: The type of the `I`th element of `T`. Equivalent to `__result_of_value_at__::type`. + +[endsect] + +[section Element access] + +[heading Description] +The __tr1__tuple__ provides the `get` function to provide access to it's elements by zero based numeric index. + +[heading Specification] + template + RJ get(T& t); + +[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds. +`T` is any fusion sequence type, including `tuple`. + +[*Return type]: `RJ` is equivalent to `__result_of_at_c__::type`. + +[*Returns]: A reference to the `I`th element of `T`. + + template + PJ get(T const& t); + +[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds. +`T` is any fusion sequence type, including `tuple`. + +[*Return type]: `PJ` is equivalent to `__result_of_at_c__::type`. + +[*Returns]: A const reference to the `I`th element of `T`. + +[endsect] + +[section Relational operators] + +[heading Description] +The __tr1__tuple__ provides the standard boolean relational operators. + +[heading Specification] + +[variablelist Notation + [[`T1 ... TN`, `U1 ... UN`][Tuple element types]] + [[`P1 ... PN`] [Parameter types]] + [[`Ti`, `Ui`] [The type of the `i`th element of a tuple]] + [[`Pi`] [The type of the `i`th parameter]] +] + + template + bool operator==( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(lhs) == __tuple_get__(rhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns `true` if and only if `__tuple_get__(lhs) == __tuple_get__(rhs)` for all `i`. +For any 2 zero length tuples `e` and `f`, `e == f` returns `true`. + + template + bool operator<( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(lhs) < __tuple_get__(rhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns the lexicographical comparison of between `lhs` and `rhs`. + + template + bool operator!=( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(lhs) == __tuple_get__(rhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns `!(lhs == rhs)`. + + template + bool operator<=( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(rhs) < __tuple_get__(lhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns `!(rhs < lhs)` + + template + bool operator>( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(rhs) < __tuple_get__(lhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns `rhs < lhs`. + + template + bool operator>=( + const tuple& lhs, + const tuple& rhs); + +[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__(lhs) < __tuple_get__(rhs)` is a valid +expression returning a type that is convertible to `bool`. + +[*Semantics]: Returns `!(lhs < rhs)`. + +[endsect] + +[endsect] + +[section Pairs] + +[heading Description] +The __tr1__tuple__ interface is specified to provide uniform access to `std::pair` as if it were a 2 element tuple. + +[heading Specification] + + tuple_size >::value + +[*Type]: An __mpl_integral_constant__ + +[*Value]: Returns 2, the number of elements in a pair. + + tuple_element<0, std::pair >::type + +[*Type]: `T1` + +[*Value]: Returns the type of the first element of the pair + + tuple_element<1, std::pair >::type + +[*Type]: `T2` + +[*Value]: Returns thetype of the second element of the pair + + template + P& get(std::pair& pr); + + template + const P& get(const std::pair& pr); + +[*Type]: If `I == 0` `P` is `T1`, else if `I == 1` `P` is `T2` else the program is ill-formed. + +[*Returns: `pr.first` if `I == 0` else `pr.second`. + +[endsect] + +[endsect] + diff --git a/example/extension/Jamfile.v2 b/example/extension/Jamfile.v2 new file mode 100644 index 00000000..cf062603 --- /dev/null +++ b/example/extension/Jamfile.v2 @@ -0,0 +1,18 @@ +#============================================================================== +# Copyright (c) 2003-2006 Joel de Guzman +# Copyright (c) 2006 Dan Marsden +# +# Use, modification and distribution is subject to the Boost Software +# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +#============================================================================== + +# bring in rules for testing +import testing ; + +{ + test-suite example : + + [ run test_example.cpp : : : : ] ; +} + diff --git a/example/extension/detail/advance_impl.hpp b/example/extension/detail/advance_impl.hpp new file mode 100644 index 00000000..6663c88e --- /dev/null +++ b/example/extension/detail/advance_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_ADVANCE_IMPL_20060222_2150) +#define BOOST_FUSION_ADVANCE_IMPL_20060222_2150 + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + template + struct example_struct_iterator; + + namespace extension + { + template + struct advance_impl; + + template<> + struct advance_impl + { + template + struct apply + { + typedef typename Iterator::struct_type struct_type; + typedef typename Iterator::index index; + typedef example_struct_iterator< + struct_type, index::value + N::value> type; + + static type + call(Iterator const& it) + { + return type(it.struct_); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/at_impl.hpp b/example/extension/detail/at_impl.hpp new file mode 100644 index 00000000..1fca18d9 --- /dev/null +++ b/example/extension/detail/at_impl.hpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_AT_IMPL_20060223_2017) +#define BOOST_FUSION_AT_IMPL_20060223_2017 + +#include +#include +#include +#include + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct at_impl; + + template<> + struct at_impl + { + template + struct apply; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, + std::string const&, + std::string&>::type type; + + static type + call(Sequence& seq) + { + return seq.name; + }; + }; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, + int const&, + int&>::type type; + + static type + call(Sequence& seq) + { + return seq.age; + }; + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/at_key_impl.hpp b/example/extension/detail/at_key_impl.hpp new file mode 100644 index 00000000..33761815 --- /dev/null +++ b/example/extension/detail/at_key_impl.hpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_AT_KEY_IMPL_20060223_2017) +#define BOOST_FUSION_AT_KEY_IMPL_20060223_2017 + +#include +#include +#include + +namespace fields +{ + struct name; + struct age; +} + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct at_key_impl; + + template<> + struct at_key_impl + { + template + struct apply; + + template + struct apply + { + typedef typename mpl::if_< + is_const, + std::string const&, + std::string&>::type type; + + static type + call(Sequence& seq) + { + return seq.name; + }; + }; + + template + struct apply + { + typedef typename mpl::if_< + is_const, + int const&, + int&>::type type; + + static type + call(Sequence& seq) + { + return seq.age; + }; + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/begin_impl.hpp b/example/extension/detail/begin_impl.hpp new file mode 100644 index 00000000..e24ef48b --- /dev/null +++ b/example/extension/detail/begin_impl.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_BEGIN_IMPL_20060222_2042) +#define BOOST_FUSION_BEGIN_IMPL_20060222_2042 + +#include "../example_struct_iterator.hpp" + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct begin_impl; + + template<> + struct begin_impl + { + template + struct apply + { + typedef example_struct_iterator type; + + static type + call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/category_of_impl.hpp b/example/extension/detail/category_of_impl.hpp new file mode 100644 index 00000000..f3fbf63e --- /dev/null +++ b/example/extension/detail/category_of_impl.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037) +#define BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037 + +namespace boost { namespace fusion { + + struct random_access_traversal_tag; + + namespace extension + { + template + struct category_of_impl; + + template<> + struct category_of_impl + { + template + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/deref_impl.hpp b/example/extension/detail/deref_impl.hpp new file mode 100644 index 00000000..2be589d6 --- /dev/null +++ b/example/extension/detail/deref_impl.hpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_DEREF_IMPL_20060222_1952) +#define BOOST_FUSION_DEREF_IMPL_20060222_1952 + +#include +#include +#include + +#include + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + template + struct example_struct_iterator; + + namespace extension + { + template + struct deref_impl; + + template<> + struct deref_impl + { + template + struct apply; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, std::string const&, std::string&>::type type; + + static type + call(example_struct_iterator const& it) + { + return it.struct_.name; + } + }; + + template + struct apply > + { + typedef typename mpl::if_< + is_const, int const&, int&>::type type; + + static type + call(example_struct_iterator const& it) + { + return it.struct_.age; + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/distance_impl.hpp b/example/extension/detail/distance_impl.hpp new file mode 100644 index 00000000..d576cdb7 --- /dev/null +++ b/example/extension/detail/distance_impl.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_DISTANCE_IMPL_20060223_0814) +#define BOOST_FUSION_DISTANCE_IMPL_20060223_0814 + +#include + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + namespace extension + { + template + struct distance_impl; + + template<> + struct distance_impl + { + template + struct apply + : mpl::minus + { + typedef apply self; + + static typename self::type + call(First const& first, Last const& last) + { + return typename self::type(); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/end_impl.hpp b/example/extension/detail/end_impl.hpp new file mode 100644 index 00000000..197ed5b7 --- /dev/null +++ b/example/extension/detail/end_impl.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_END_IMPL_20060222_2042) +#define BOOST_FUSION_END_IMPL_20060222_2042 + +#include "../example_struct_iterator.hpp" + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct end_impl; + + template<> + struct end_impl + { + template + struct apply + { + typedef example_struct_iterator type; + + static type + call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/equal_to_impl.hpp b/example/extension/detail/equal_to_impl.hpp new file mode 100644 index 00000000..6ab5841f --- /dev/null +++ b/example/extension/detail/equal_to_impl.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941) +#define BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941 + +#include + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + namespace extension + { + template + struct equal_to_impl; + + template<> + struct equal_to_impl + { + template + struct apply + : mpl::equal_to< + typename It1::index, + typename It2::index> + {}; + }; + } +}} + +#endif diff --git a/example/extension/detail/has_key_impl.hpp b/example/extension/detail/has_key_impl.hpp new file mode 100644 index 00000000..45cd554c --- /dev/null +++ b/example/extension/detail/has_key_impl.hpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_HAS_KEY_IMPL_20060223_2156) +#define BOOST_FUSION_HAS_KEY_IMPL_20060223_2156 + +#include +#include + +namespace fields +{ + struct name; + struct age; +} + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct has_key_impl; + + template<> + struct has_key_impl + { + template + struct apply + : mpl::or_< + is_same, + is_same > + {}; + }; + } +}} + +#endif diff --git a/example/extension/detail/is_associative_impl.hpp b/example/extension/detail/is_associative_impl.hpp new file mode 100644 index 00000000..18fc9922 --- /dev/null +++ b/example/extension/detail/is_associative_impl.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324) +#define BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324 + +#include + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct is_associative_impl; + + template<> + struct is_associative_impl + { + template + struct apply + : mpl::true_ + {}; + }; + } +}} + +#endif diff --git a/example/extension/detail/is_sequence_impl.hpp b/example/extension/detail/is_sequence_impl.hpp new file mode 100644 index 00000000..b8c9bede --- /dev/null +++ b/example/extension/detail/is_sequence_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946 + +#include + +namespace boost { namespace fusion +{ + struct example_sequence_tag; + + namespace extension + { + template + struct is_sequence_impl; + + template<> + struct is_sequence_impl + { + template + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/example/extension/detail/is_view_impl.hpp b/example/extension/detail/is_view_impl.hpp new file mode 100644 index 00000000..957051d5 --- /dev/null +++ b/example/extension/detail/is_view_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_IS_VIEW_IMPL_200604227_2150) +#define BOOST_FUSION_IS_VIEW_IMPL_200604227_2150 + +#include + +namespace boost { namespace fusion +{ + struct example_sequence_tag; + + namespace extension + { + template + struct is_view_impl; + + template<> + struct is_view_impl + : boost::mpl::false_ + {}; + } +}} + +#endif diff --git a/example/extension/detail/next_impl.hpp b/example/extension/detail/next_impl.hpp new file mode 100644 index 00000000..c83f414d --- /dev/null +++ b/example/extension/detail/next_impl.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_NEXT_IMPL_20060222_1859) +#define BOOST_FUSION_NEXT_IMPL_20060222_1859 + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + template + struct example_struct_iterator; + + namespace extension + { + template + struct next_impl; + + template<> + struct next_impl + { + template + struct apply + { + typedef typename Iterator::struct_type struct_type; + typedef typename Iterator::index index; + typedef example_struct_iterator type; + + static type + call(Iterator const& i) + { + return type(i.struct_); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/prior_impl.hpp b/example/extension/detail/prior_impl.hpp new file mode 100644 index 00000000..5f8a7d22 --- /dev/null +++ b/example/extension/detail/prior_impl.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_PRIOR_IMPL_20060222_1944) +#define BOOST_FUSION_PRIOR_IMPL_20060222_1944 + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + template + struct example_struct_iterator; + + namespace extension + { + template + struct prior_impl; + + template<> + struct prior_impl + { + template + struct apply + { + typedef typename Iterator::struct_type struct_type; + typedef typename Iterator::index index; + typedef example_struct_iterator type; + + static type + call(Iterator const& i) + { + return type(i.struct_); + } + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/size_impl.hpp b/example/extension/detail/size_impl.hpp new file mode 100644 index 00000000..4e62331f --- /dev/null +++ b/example/extension/detail/size_impl.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_SIZE_IMPL_20060223_2033) +#define BOOST_FUSION_SIZE_IMPL_20060223_2033 + +#include + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct size_impl; + + template<> + struct size_impl + { + template + struct apply + : mpl::int_<2> + {}; + }; + } +}} + +#endif diff --git a/example/extension/detail/value_at_impl.hpp b/example/extension/detail/value_at_impl.hpp new file mode 100644 index 00000000..9685e88c --- /dev/null +++ b/example/extension/detail/value_at_impl.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_VALUE_AT_IMPL_20060223_2025) +#define BOOST_FUSION_VALUE_AT_IMPL_20060223_2025 + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct value_at_impl; + + template<> + struct value_at_impl + { + template + struct apply; + + template + struct apply > + { + typedef std::string type; + }; + + template + struct apply > + { + typedef int type; + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/value_at_key_impl.hpp b/example/extension/detail/value_at_key_impl.hpp new file mode 100644 index 00000000..52b246bb --- /dev/null +++ b/example/extension/detail/value_at_key_impl.hpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025) +#define BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025 + +namespace fields +{ + struct name; + struct age; +} + +namespace boost { namespace fusion { + + struct example_sequence_tag; + + namespace extension + { + template + struct value_at_key_impl; + + template<> + struct value_at_key_impl + { + template + struct apply; + + template + struct apply + { + typedef std::string type; + }; + + template + struct apply + { + typedef int type; + }; + }; + } +}} + +#endif diff --git a/example/extension/detail/value_of_impl.hpp b/example/extension/detail/value_of_impl.hpp new file mode 100644 index 00000000..2d2d33c5 --- /dev/null +++ b/example/extension/detail/value_of_impl.hpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_VALUE_OF_IMPL_20060223_1905) +#define BOOST_FUSION_VALUE_OF_IMPL_20060223_1905 + +#include + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + + template + struct example_struct_iterator; + + namespace extension + { + template + struct value_of_impl; + + template<> + struct value_of_impl + { + template + struct apply; + + template + struct apply > + { + typedef std::string type; + }; + + template + struct apply > + { + typedef int type; + }; + + }; + } +}} + +#endif diff --git a/example/extension/example_struct.hpp b/example/extension/example_struct.hpp new file mode 100644 index 00000000..9e742ae3 --- /dev/null +++ b/example/extension/example_struct.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_EXAMPLE_STRUCT) +#define BOOST_FUSION_EXAMPLE_STRUCT + +#include "./tag_of.hpp" +#include "./example_struct_iterator.hpp" +#include "./detail/begin_impl.hpp" +#include "./detail/end_impl.hpp" +#include "./detail/at_impl.hpp" +#include "./detail/value_at_impl.hpp" +#include "./detail/size_impl.hpp" +#include "./detail/category_of_impl.hpp" +#include "./detail/at_key_impl.hpp" +#include "./detail/value_at_key_impl.hpp" +#include "./detail/has_key_impl.hpp" +#include "./detail/is_sequence_impl.hpp" +#include "./detail/is_associative_impl.hpp" +#include "./detail/is_view_impl.hpp" + +#endif diff --git a/example/extension/example_struct_iterator.hpp b/example/extension/example_struct_iterator.hpp new file mode 100644 index 00000000..3f60b914 --- /dev/null +++ b/example/extension/example_struct_iterator.hpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR) +#define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR + +#include +#include +#include +#include + +#include "./detail/next_impl.hpp" +#include "./detail/prior_impl.hpp" +#include "./detail/deref_impl.hpp" +#include "./detail/advance_impl.hpp" +#include "./detail/distance_impl.hpp" +#include "./detail/value_of_impl.hpp" +#include "./detail/equal_to_impl.hpp" + +namespace boost { namespace fusion { + + struct example_struct_iterator_tag; + struct random_access_traversal_tag; + + template + struct example_struct_iterator + : iterator_base > + { + BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3); + typedef Struct struct_type; + typedef mpl::int_ index; + typedef example_struct_iterator_tag ftag; + typedef random_access_traversal_tag category; + + example_struct_iterator(Struct& str) + : struct_(str) {} + + Struct& struct_; + }; +}} + +#endif diff --git a/example/extension/example_struct_type.hpp b/example/extension/example_struct_type.hpp new file mode 100644 index 00000000..543c9b69 --- /dev/null +++ b/example/extension/example_struct_type.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_TYPE) +#define BOOST_FUSION_EXAMPLE_STRUCT_TYPE + +#include + +namespace example +{ + struct example_struct + { + std::string name; + int age; + example_struct( + const std::string& n, + int a) + : name(n), age(a) + {} + }; +} + +#endif diff --git a/example/extension/tag_of.hpp b/example/extension/tag_of.hpp new file mode 100644 index 00000000..dfe06dfc --- /dev/null +++ b/example/extension/tag_of.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_TAG_OF_20060222_2052) +#define BOOST_FUSION_TAG_OF_20060222_2052 + +#include +#include "./example_struct_type.hpp" + +namespace boost { namespace fusion { + + struct example_sequence_tag; + +namespace traits { + + template<> + struct tag_of + { + typedef example_sequence_tag type; + }; +}}} + +#endif diff --git a/example/extension/test_example.cpp b/example/extension/test_example.cpp new file mode 100644 index 00000000..8a858c0b --- /dev/null +++ b/example/extension/test_example.cpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include "./example_struct.hpp" +#include "./example_struct_type.hpp" +#include + +#include +#include +#include +#include +#include +#include + +int main() +{ + example::example_struct bert("bert", 99); + using namespace boost::fusion; + BOOST_MPL_ASSERT((traits::is_associative)); + BOOST_TEST(*begin(bert) == "bert"); + BOOST_TEST(*next(begin(bert)) == 99); + BOOST_TEST(*prior(end(bert)) == 99); + BOOST_TEST(*advance_c<1>(begin(bert)) == 99); + BOOST_TEST(*advance_c<-1>(end(bert)) == 99); + BOOST_TEST(distance(begin(bert), end(bert)) == 2); + + typedef result_of::begin::type first; + typedef result_of::next::type second; + BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + BOOST_TEST(begin(bert) != end(bert)); + BOOST_TEST(advance_c<2>(begin(bert)) == end(const_cast(bert))); + + BOOST_TEST(at_c<0>(bert) == "bert"); + BOOST_TEST(at_c<1>(bert) == 99); + + BOOST_TEST(at_key(bert) == "bert"); + BOOST_TEST(at_key(bert) == 99); + + BOOST_TEST(has_key(bert)); + BOOST_TEST(has_key(bert)); + BOOST_TEST(!has_key(bert)); + + BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + BOOST_TEST(size(bert) == 2); + + BOOST_MPL_ASSERT((boost::is_same::type, random_access_traversal_tag>)); + + BOOST_MPL_ASSERT((traits::is_sequence)); + + return boost::report_errors(); +} diff --git a/index.html b/index.html new file mode 100644 index 00000000..b6ce29ba --- /dev/null +++ b/index.html @@ -0,0 +1,10 @@ + + + + + + + Automatic redirection failed, click this + link + + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 new file mode 100644 index 00000000..437efad6 --- /dev/null +++ b/test/Jamfile.v2 @@ -0,0 +1,96 @@ +#============================================================================== +# Copyright (c) 2003-2006 Joel de Guzman +# +# Use, modification and distribution is subject to the Boost Software +# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +#============================================================================== + +# bring in rules for testing +import testing ; + +{ + test-suite fusion : + + [ run algorithm/all.cpp : : : : ] + [ run algorithm/any.cpp : : : : ] + [ run algorithm/clear.cpp : : : : ] + [ run algorithm/count.cpp : : : : ] + [ run algorithm/count_if.cpp : : : : ] + [ run algorithm/erase.cpp : : : : ] + [ run algorithm/erase_key.cpp : : : : ] + [ run algorithm/filter.cpp : : : : ] + [ run algorithm/filter_if.cpp : : : : ] + [ run algorithm/find.cpp : : : : ] + [ run algorithm/find_if.cpp : : : : ] + [ run algorithm/fold.cpp : : : : ] + [ run algorithm/for_each.cpp : : : : ] + [ run algorithm/insert.cpp : : : : ] + [ run algorithm/insert_range.cpp : : : : ] + [ run algorithm/none.cpp : : : : ] + [ run algorithm/pop_back.cpp : : : : ] + [ run algorithm/pop_front.cpp : : : : ] + [ run algorithm/push_back.cpp : : : : ] + [ run algorithm/push_front.cpp : : : : ] + [ run algorithm/remove.cpp : : : : ] + [ run algorithm/remove_if.cpp : : : : ] + [ run algorithm/replace.cpp : : : : ] + [ run algorithm/replace_if.cpp : : : : ] + [ run algorithm/reverse.cpp : : : : ] + [ run algorithm/transform.cpp : : : : ] + [ run algorithm/join.cpp : : : : ] + [ run algorithm/zip.cpp : : : : ] + + [ run sequence/as_list.cpp : : : : ] + [ run sequence/as_map.cpp : : : : ] + [ run sequence/as_set.cpp : : : : ] + [ run sequence/as_vector.cpp : : : : ] + [ run sequence/cons.cpp : : : : ] + [ run sequence/filter_view.cpp : : : : ] + [ run sequence/io.cpp : : : : ] + [ run sequence/iterator_range.cpp : : : : ] + [ run sequence/joint_view.cpp : : : : ] + [ run sequence/list_comparison.cpp : : : : ] + [ run sequence/list_construction.cpp : : : : ] + [ run sequence/list_copy.cpp : : : : ] + [ run sequence/list_iterator.cpp : : : : ] + [ run sequence/list_make.cpp : : : : ] + [ run sequence/list_misc.cpp : : : : ] + [ run sequence/list_mutate.cpp : : : : ] + [ run sequence/list_tie.cpp : : : : ] + [ run sequence/list_value_at.cpp : : : : ] + [ run sequence/make_list.cpp : : : : ] + [ run sequence/make_vector.cpp : : : : ] + [ run sequence/map.cpp : : : : ] + [ run sequence/reverse_view.cpp : : : : ] + [ run sequence/set.cpp : : : : ] + [ run sequence/single_view.cpp : : : : ] + [ run sequence/std_pair.cpp : : : : ] + [ run sequence/array.cpp : : : : ] + [ run sequence/tuple_comparison.cpp : : : : ] + [ run sequence/tuple_construction.cpp : : : : ] + [ run sequence/tuple_copy.cpp : : : : ] + [ run sequence/tuple_element.cpp : : : : ] + [ run sequence/tuple_make.cpp : : : : ] + [ run sequence/tuple_misc.cpp : : : : ] + [ run sequence/tuple_mutate.cpp : : : : ] + [ run sequence/tuple_tie.cpp : : : : ] + [ run sequence/transform_view.cpp : : : : ] + [ run sequence/unpack_args.cpp ] + [ run sequence/vector_comparison.cpp : : : : ] + [ run sequence/vector_construction.cpp : : : : ] + [ run sequence/vector_copy.cpp : : : : ] + [ run sequence/vector_iterator.cpp : : : : ] + [ run sequence/vector_make.cpp : : : : ] + [ run sequence/vector_misc.cpp : : : : ] + [ run sequence/vector_mutate.cpp : : : : ] + [ run sequence/vector_n.cpp : : : : ] + [ run sequence/vector_tie.cpp : : : : ] + [ run sequence/vector_value_at.cpp : : : : ] + [ run sequence/zip_view.cpp : : : : ] + [ run sequence/zip_view2.cpp : : : : ] +# [ compile-fail xxx.cpp : : : : ] + + ; +} + diff --git a/test/algorithm/all.cpp b/test/algorithm/all.cpp new file mode 100644 index 00000000..8cc75586 --- /dev/null +++ b/test/algorithm/all.cpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int +main() +{ + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4))); + BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0))); + } + + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 == 1))); + BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 < 3))); + } + + { + typedef boost::mpl::vector_c mpl_vec; + BOOST_TEST(boost::fusion::all(mpl_vec(), boost::lambda::_1 < 4)); + BOOST_TEST(!boost::fusion::all(mpl_vec(), boost::lambda::_1 == 2)); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/any.cpp b/test/algorithm/any.cpp new file mode 100644 index 00000000..5b7ab2ed --- /dev/null +++ b/test/algorithm/any.cpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005 Eric Niebler + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int +main() +{ + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST(boost::fusion::any(t, boost::lambda::_1 == 2)); + } + + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3)); + } + + { + typedef boost::mpl::vector_c mpl_vec; + BOOST_TEST(boost::fusion::any(mpl_vec(), boost::lambda::_1 == 2)); + BOOST_TEST(!boost::fusion::any(mpl_vec(), boost::lambda::_1 == 4)); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/clear.cpp b/test/algorithm/clear.cpp new file mode 100644 index 00000000..830e3821 --- /dev/null +++ b/test/algorithm/clear.cpp @@ -0,0 +1,46 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing pop_back + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + + { + std::cout << clear(t1) << std::endl; + BOOST_TEST((clear(t1) == make_vector())); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + std::cout << boost::fusion::clear(mpl_vec()) << std::endl; + BOOST_TEST((boost::fusion::clear(mpl_vec()) == make_vector())); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/count.cpp b/test/algorithm/count.cpp new file mode 100644 index 00000000..718427c2 --- /dev/null +++ b/test/algorithm/count.cpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005 Eric Niebler + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int +main() +{ + { + boost::fusion::vector t(1, 1, 1); + BOOST_TEST(boost::fusion::count(t, 1) == 3); + } + + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST(boost::fusion::count(t, 3) == 0); + } + + { + boost::fusion::vector t(4, "hello", 4); + BOOST_TEST(boost::fusion::count(t, "hello") == 1); + } + + { + typedef boost::mpl::vector_c mpl_vec; + BOOST_TEST(boost::fusion::count(mpl_vec(), 2) == 3); + BOOST_TEST(boost::fusion::count(mpl_vec(), 3) == 2); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/count_if.cpp b/test/algorithm/count_if.cpp new file mode 100644 index 00000000..3130cdc4 --- /dev/null +++ b/test/algorithm/count_if.cpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005 Eric Niebler + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int +main() +{ + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 2) == 1); + } + + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 3) == 0); + } + + { + typedef boost::mpl::vector_c mpl_vec; + BOOST_TEST(boost::fusion::count_if(mpl_vec(), boost::lambda::_1 <= 2) == 2); + BOOST_TEST(boost::fusion::count_if(mpl_vec(), boost::lambda::_1 > 2) == 1); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/erase.cpp b/test/algorithm/erase.cpp new file mode 100644 index 00000000..97520964 --- /dev/null +++ b/test/algorithm/erase.cpp @@ -0,0 +1,64 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::vector_c; + using boost::mpl::begin; + using boost::mpl::advance; + using boost::mpl::int_; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing erase + + { + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, "Ruby"); + vector_iterator pos(t1); + + std::cout << erase(t1, pos) << std::endl; + BOOST_TEST((erase(t1, pos) == make_vector(1, 'x', std::string("Ruby")))); + BOOST_TEST((erase(t1, end(t1)) == make_vector(1, 'x', 3.3, std::string("Ruby")))); + } + + { + typedef vector_c mpl_vec; + typedef boost::mpl::begin::type mpl_vec_begin; + typedef boost::mpl::advance >::type mpl_vec_at3; + typedef boost::mpl::next::type n1; + typedef boost::mpl::next::type n2; + typedef boost::mpl::next::type n3; + + BOOST_STATIC_ASSERT((boost::is_same::value)); + + + std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl; + BOOST_TEST((erase(mpl_vec(), mpl_vec_at3()) + == make_vector(1, 2, 3, 5))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/erase_key.cpp b/test/algorithm/erase_key.cpp new file mode 100644 index 00000000..1540ff6e --- /dev/null +++ b/test/algorithm/erase_key.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void test_set(Set const& set) +{ + using namespace boost::fusion; + std::cout << set << std::endl; + + BOOST_STATIC_ASSERT(result_of::size::value == 3); + BOOST_TEST((*find(set) == 1)); + BOOST_TEST((*find(set) == 1.5)); + BOOST_TEST((*find(set) == "hello")); +} + +typedef boost::mpl::int_<1> _1; +typedef boost::mpl::int_<2> _2; +typedef boost::mpl::int_<3> _3; +typedef boost::mpl::int_<4> _4; + +template +void test_map(Map const& map) +{ + using namespace boost::fusion; + std::cout << map << std::endl; + + BOOST_STATIC_ASSERT(result_of::size::value == 3); + BOOST_TEST(((*find<_1>(map)).second == 1)); + BOOST_TEST(((*find<_3>(map)).second == 1.5)); + BOOST_TEST(((*find<_4>(map)).second == std::string("hello"))); +} + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + using namespace std; + using boost::fusion::pair; + using boost::fusion::make_pair; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + test_set(as_set(erase_key(make_set(1, 'x', 1.5, std::string("hello"))))); + test_map(as_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello")))); + + return boost::report_errors(); +} + diff --git a/test/algorithm/filter.cpp b/test/algorithm/filter.cpp new file mode 100644 index 00000000..196e37b8 --- /dev/null +++ b/test/algorithm/filter.cpp @@ -0,0 +1,44 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + typedef boost::fusion::vector vector_type; + vector_type t('a', 6.6, 'b'); + + { + std::cout << filter(t) << std::endl; + BOOST_TEST((filter(t) + == make_vector('a', 'b'))); + } + + { + typedef boost::mpl::vector mpl_vec; + BOOST_TEST((filter(mpl_vec()) + == make_vector('\0', '\0'))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/filter_if.cpp b/test/algorithm/filter_if.cpp new file mode 100644 index 00000000..b8b80735 --- /dev/null +++ b/test/algorithm/filter_if.cpp @@ -0,0 +1,78 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator char const*() const + { + return ""; + } +}; + +struct Y +{ + operator char const*() const + { + return ""; + } +}; + +int +main() +{ + using namespace boost::fusion; + + using boost::mpl::_; + using boost::mpl::not_; + using boost::is_class; + using boost::is_same; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing filter_if + + X x; Y y; + typedef boost::fusion::vector vector_type; + vector_type t(y, '@', 987654, x, true, 6.6); + + { + std::cout << filter_if > >(t) << std::endl; + BOOST_TEST((filter_if > >(t) + == make_vector('@', 987654, true, 6.6))); + } + + { + std::cout << filter_if >(t) << std::endl; + BOOST_TEST((filter_if >(t) + == make_vector(y, x))); + } + + { + typedef boost::mpl::vector mpl_vec; + BOOST_TEST((filter_if > >(mpl_vec()) + == make_vector(char(), long(), bool()))); + BOOST_TEST((filter_if >(mpl_vec()) + == make_vector(y, x))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/find.cpp b/test/algorithm/find.cpp new file mode 100644 index 00000000..3bf4d1b3 --- /dev/null +++ b/test/algorithm/find.cpp @@ -0,0 +1,80 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator int() const + { + return 12345; + } +}; +int +main() +{ + using namespace boost::fusion; + using boost::mpl::identity; + + { + typedef vector seq_type; + seq_type seq(12345, 'x', 678910, 3.36); + + std::cout << *boost::fusion::find(seq) << std::endl; + BOOST_TEST(*boost::fusion::find(seq) == 'x'); + + std::cout << *boost::fusion::find(seq) << std::endl; + BOOST_TEST(*boost::fusion::find(seq) == 12345); + + std::cout << *boost::fusion::find(seq) << std::endl; + BOOST_TEST(*boost::fusion::find(seq) == 3.36); + + BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); + } + + { + typedef set seq_type; + seq_type seq(12345, 'x', 3.36); + std::cout << *boost::fusion::find(seq) << std::endl; + BOOST_TEST(*boost::fusion::find(seq) == 'x'); + BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); + } + + { + typedef map< + pair + , pair > + map_type; + + map_type seq( + make_pair('X') + , make_pair("Men")); + + std::cout << *boost::fusion::find(seq) << std::endl; + std::cout << *boost::fusion::find(seq) << std::endl; + BOOST_TEST((*boost::fusion::find(seq)).second == 'X'); + BOOST_TEST((*boost::fusion::find(seq)).second == "Men"); + BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); + } + + { + typedef boost::mpl::vector mpl_vec; + BOOST_TEST((*boost::fusion::find(mpl_vec()) == 12345)); + BOOST_TEST(boost::fusion::find(mpl_vec()) == boost::fusion::end(mpl_vec())); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/find_if.cpp b/test/algorithm/find_if.cpp new file mode 100644 index 00000000..18e262b2 --- /dev/null +++ b/test/algorithm/find_if.cpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator int() const + { + return 12345; + } +}; + +int +main() +{ + using namespace boost::fusion; + + { + using boost::is_same; + using boost::mpl::_; + + typedef vector vector_type; + vector_type v(12345, 'x', 678910, 3.36); + + std::cout << *find_if >(v) << std::endl; + BOOST_TEST((*find_if >(v) == 'x')); + + std::cout << *find_if >(v) << std::endl; + BOOST_TEST((*find_if >(v) == 12345)); + + std::cout << *find_if >(v) << std::endl; + BOOST_TEST((*find_if >(v) == 3.36)); + } + + { + using boost::mpl::vector; + using boost::is_same; + using boost::mpl::_; + + typedef vector mpl_vec; + BOOST_TEST((*find_if >(mpl_vec()) == 12345)); + } + + { + using boost::mpl::vector_c; + using boost::mpl::less; + using boost::mpl::int_; + using boost::is_same; + using boost::mpl::_; + + typedef vector_c mpl_vec; + BOOST_TEST((*find_if > >(mpl_vec()) == 1)); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp new file mode 100644 index 00000000..61dc3e91 --- /dev/null +++ b/test/algorithm/fold.cpp @@ -0,0 +1,110 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using boost::mpl::if_; +using boost::mpl::int_; +using boost::is_same; + +struct add_ints_only +{ + template + struct result + { + typedef State type; + }; + + template + State const& + operator()(T const& x, State const& state) const + { + return state; + } + + int + operator()(int x, int state) const + { + return x + state; + } +}; + +struct count_ints +{ + template + struct result + { + typedef typename + if_< + is_same + , typename boost::mpl::next::type + , CountT + >::type + type; + }; + + template + typename result::type + operator()(T const&, CountT const&) const + { + typedef typename result::type result; + return result(); + } +}; + +int +main() +{ + using namespace boost::fusion; + namespace fusion = boost::fusion; + + { + typedef vector vector_type; + vector_type v(12345, 'x', 678910, 3.36); + int result = fold(v, 0, add_ints_only()); + std::cout << result << std::endl; + BOOST_TEST(result == 12345+678910); + } + + { + typedef vector vector_type; + vector_type v(12345); + + int n = fusion::fold(v, int_<0>(), count_ints()); + std::cout << n << std::endl; + BOOST_TEST(n == 1); + } + + { + typedef vector vector_type; + vector_type v(12345, 'x', 678910, 3.36, 8756); + + int n = fusion::fold(v, int_<0>(), count_ints()); + std::cout << n << std::endl; + BOOST_TEST(n == 3); + } + + { + typedef boost::mpl::vector mpl_vec; + int n = fusion::fold(mpl_vec(), int_<0>(), count_ints()); + std::cout << n << std::endl; + BOOST_TEST(n == 3); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/for_each.cpp b/test/algorithm/for_each.cpp new file mode 100644 index 00000000..26a9831d --- /dev/null +++ b/test/algorithm/for_each.cpp @@ -0,0 +1,62 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +struct print +{ + template + void operator()(T const& v) const + { + std::cout << "[ " << v << " ] "; + } +}; + +struct increment +{ + template + void operator()(T& v) const + { + ++v; + } +}; + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::vector_c; + namespace fusion = boost::fusion; + + { + typedef vector vector_type; + vector_type v(1, 'x', 3.3, "Ruby"); + for_each(v, print()); + std::cout << std::endl; + } + + { + typedef vector vector_type; + vector_type v(1, 'x', 3.3, "Ruby"); + for_each(v, increment()); + std::cout << v << std::endl; + } + + { + typedef vector_c mpl_vec; + fusion::for_each(mpl_vec(), print()); + std::cout << std::endl; + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/insert.cpp b/test/algorithm/insert.cpp new file mode 100644 index 00000000..da3858ad --- /dev/null +++ b/test/algorithm/insert.cpp @@ -0,0 +1,68 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::vector_c; + using boost::mpl::advance; + using boost::mpl::int_; + namespace fusion = boost::fusion; + namespace mpl = boost::mpl; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing insert + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + vector_iterator pos(t1); + + std::cout << insert(t1, pos, 123456) << std::endl; + BOOST_TEST((insert(t1, pos, 123456) + == make_vector(1, 'x', 123456, 3.3, s))); + + std::cout << insert(t1, end(t1), 123456) << std::endl; + BOOST_TEST((insert(t1, end(t1), 123456) + == make_vector(1, 'x', 3.3, s, 123456))); + + std::cout << insert(t1, begin(t1), "glad") << std::endl; + BOOST_TEST((insert(t1, begin(t1), "glad") + == make_vector(std::string("glad"), 1, 'x', 3.3, s))); + } + + { + typedef vector_c mpl_vec; + typedef mpl::begin::type mpl_vec_begin; + typedef advance >::type mpl_vec_at3; + + std::cout << fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>()) << std::endl; + BOOST_TEST((fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>()) + == make_vector(1, 2, 3, 66, 4, 5))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/insert_range.cpp b/test/algorithm/insert_range.cpp new file mode 100644 index 00000000..030d194c --- /dev/null +++ b/test/algorithm/insert_range.cpp @@ -0,0 +1,72 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::vector_c; + using boost::mpl::advance; + using boost::mpl::int_; + namespace fusion = boost::fusion; + namespace mpl = boost::mpl; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing insert_range + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + vector_iterator pos(t1); + + typedef vector vector_type2; + vector_type2 t2(999, 'z'); + + std::cout << insert_range(t1, pos, t2) << std::endl; + BOOST_TEST((insert_range(t1, pos, t2) + == make_vector(1, 'x', 999, 'z', 3.3, s))); + + std::cout << insert_range(t1, end(t1), t2) << std::endl; + BOOST_TEST((insert_range(t1, end(t1), t2) + == make_vector(1, 'x', 3.3, s, 999, 'z'))); + + std::cout << insert_range(t1, begin(t1), t2) << std::endl; + BOOST_TEST((insert_range(t1, begin(t1), t2) + == make_vector(999, 'z', 1, 'x', 3.3, s))); + } + + { + typedef vector_c mpl_vec; + typedef mpl::begin::type mpl_vec_begin; + typedef advance >::type mpl_vec_at3; + typedef vector_c mpl_vec2; + + std::cout << fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2()) << std::endl; + BOOST_TEST((fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2()) + == make_vector(1, 2, 3, -1, -2, 4, 5))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/join.cpp b/test/algorithm/join.cpp new file mode 100644 index 00000000..9a5ec800 --- /dev/null +++ b/test/algorithm/join.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int main() +{ + using namespace boost::fusion; + { + BOOST_TEST(join(make_vector(1,2), make_vector('a','b')) == make_vector(1,2,'a','b')); + } + { + typedef boost::mpl::vector2_c vec1; + typedef boost::mpl::vector2_c vec2; + BOOST_TEST(join(vec1(), vec2()) == make_vector(1,2,3,4)); + + } + return boost::report_errors(); +} diff --git a/test/algorithm/none.cpp b/test/algorithm/none.cpp new file mode 100644 index 00000000..00d355be --- /dev/null +++ b/test/algorithm/none.cpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int +main() +{ + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 > 4))); + BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 < 0))); + } + + { + boost::fusion::vector t(1, 2, 3.3); + BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 == 1))); + BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3))); + } + + { + typedef boost::mpl::vector_c mpl_vec; + BOOST_TEST(boost::fusion::none(mpl_vec(), boost::lambda::_1 > 4)); + BOOST_TEST(!boost::fusion::none(mpl_vec(), boost::lambda::_1 != 2)); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp new file mode 100644 index 00000000..7f2b3438 --- /dev/null +++ b/test/algorithm/pop_back.cpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing pop_back + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + + { + std::cout << pop_back(t1) << std::endl; + BOOST_TEST((pop_back(t1) == make_vector(1, 'x', 3.3))); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + std::cout << boost::fusion::pop_back(mpl_vec()) << std::endl; + BOOST_TEST((boost::fusion::pop_back(mpl_vec()) == make_vector(1, 2, 3, 4))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/pop_front.cpp b/test/algorithm/pop_front.cpp new file mode 100644 index 00000000..0daea5cd --- /dev/null +++ b/test/algorithm/pop_front.cpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing pop_front + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + + { + std::cout << pop_front(t1) << std::endl; + BOOST_TEST((pop_front(t1) == make_vector('x', 3.3, s))); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + std::cout << boost::fusion::pop_front(mpl_vec()) << std::endl; + BOOST_TEST((boost::fusion::pop_front(mpl_vec()) == make_vector(2, 3, 4, 5))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/push_back.cpp b/test/algorithm/push_back.cpp new file mode 100644 index 00000000..b2b1386a --- /dev/null +++ b/test/algorithm/push_back.cpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct plus_one +{ + template + void operator()(T& v) const + { + v += 1; + } +}; + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing push_back + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + + { + std::cout << push_back(t1, 123456) << std::endl; + BOOST_TEST((push_back(t1, 123456) + == make_vector(1, 'x', 3.3, s, 123456))); + } + + { + std::cout << push_back(t1, "funny") << std::endl; + BOOST_TEST((push_back(t1, "funny") + == make_vector(1, 'x', 3.3, s, std::string("funny")))); + } + + { + std::cout << push_back(t1, t1) << std::endl; + BOOST_TEST((push_back(t1, t1) + == make_vector(1, 'x', 3.3, s, t1))); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + std::cout << boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>()) << std::endl; + BOOST_TEST((boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>()) + == make_vector(1, 2, 3, 4, 5, 6))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/push_front.cpp b/test/algorithm/push_front.cpp new file mode 100644 index 00000000..c2c4dc70 --- /dev/null +++ b/test/algorithm/push_front.cpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing push_front + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3.3, s); + + { + std::cout << push_front(t1, 123456) << std::endl; + BOOST_TEST((push_front(t1, 123456) + == make_vector(123456, 1, 'x', 3.3, s))); + } + + { + std::cout << push_front(t1, "lively") << std::endl; + BOOST_TEST((push_front(t1, "lively") + == make_vector(std::string("lively"), 1, 'x', 3.3, s))); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + std::cout << boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>()) << std::endl; + BOOST_TEST((boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>()) + == make_vector(1, 2, 3, 4, 5, 6))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/remove.cpp b/test/algorithm/remove.cpp new file mode 100644 index 00000000..cdc69ff3 --- /dev/null +++ b/test/algorithm/remove.cpp @@ -0,0 +1,81 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator char const*() const + { + return ""; + } +}; + +struct Y +{ + operator char const*() const + { + return ""; + } +}; + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::identity; + using boost::mpl::vector; + namespace fusion = boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing remove + + X x; Y y; + typedef fusion::vector vector_type; + vector_type t(y, '@', 987654, x, true, 6.6); + + { + std::cout << fusion::remove(t) << std::endl; + BOOST_TEST((fusion::remove(t) + == make_vector(y, '@', 987654, true, 6.6))); + } + + { + std::cout << fusion::remove(t) << std::endl; + BOOST_TEST((fusion::remove(t) + == make_vector('@', 987654, x, true, 6.6))); + } + + { + std::cout << fusion::remove(t) << std::endl; + BOOST_TEST((fusion::remove(t) + == make_vector(y, '@', x, true, 6.6))); + } + + { + typedef vector mpl_vec; + BOOST_TEST((fusion::remove(mpl_vec()) + == vector())); + BOOST_TEST((fusion::remove(mpl_vec()) + == vector())); + BOOST_TEST((fusion::remove(mpl_vec()) + == vector())); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/remove_if.cpp b/test/algorithm/remove_if.cpp new file mode 100644 index 00000000..8268e7f9 --- /dev/null +++ b/test/algorithm/remove_if.cpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator char const*() const + { + return ""; + } +}; + +struct Y +{ + operator char const*() const + { + return ""; + } +}; + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::vector; + using boost::mpl::_; + using boost::mpl::not_; + using boost::is_class; + using boost::is_same; + namespace fusion = boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing remove_if + + X x; Y y; + typedef fusion::vector vector_type; + vector_type t(y, '@', 987654, x, true, 6.6); + + { + std::cout << remove_if > >(t) << std::endl; + BOOST_TEST((remove_if > >(t) + == make_vector(y, x))); + } + + { + std::cout << remove_if >(t) << std::endl; + BOOST_TEST((remove_if >(t) + == make_vector('@', 987654, true, 6.6))); + } + + { + typedef vector mpl_vec; + BOOST_TEST((remove_if > >(mpl_vec()) + == vector())); + BOOST_TEST((remove_if >(mpl_vec()) + == vector())); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/replace.cpp b/test/algorithm/replace.cpp new file mode 100644 index 00000000..afdbae0c --- /dev/null +++ b/test/algorithm/replace.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing replace + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 'x', 3, s); + + { + std::cout << replace(t1, 'x', 'y') << std::endl; + BOOST_TEST((replace(t1, 'x', 'y') + == make_vector(1, 'y', 3, s))); + } + + { + char const* s2 = "funny"; + std::cout << replace(t1, s, s2) << std::endl; + BOOST_TEST((replace(t1, s, s2) + == make_vector(1, 'x', 3, s2))); + } + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/replace_if.cpp b/test/algorithm/replace_if.cpp new file mode 100644 index 00000000..f2760b0e --- /dev/null +++ b/test/algorithm/replace_if.cpp @@ -0,0 +1,53 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct gt3 +{ + template + bool operator()(T x) const + { + return x > 3; + } +}; + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing replace + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type t1(1, 2, 3.3, 4, s, 5.5); + + { + std::cout << replace_if(t1, gt3(), -456) << std::endl; + BOOST_TEST((replace_if(t1, gt3(), -456) + == make_vector(1, 2, -456, -456, s, -456))); + } + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/reverse.cpp b/test/algorithm/reverse.cpp new file mode 100644 index 00000000..a2bbcacf --- /dev/null +++ b/test/algorithm/reverse.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing the reverse_view + + { + typedef boost::mpl::range_c mpl_list1; + mpl_list1 sequence; + + std::cout << reverse(sequence) << std::endl; + BOOST_TEST((reverse(sequence) == make_vector(8, 7, 6, 5))); + } + + { + char const* s = "Hi Kim"; + typedef vector vector_type; + vector_type t(123, 'x', 3.36, s); + + std::cout << reverse(t) << std::endl; + BOOST_TEST((reverse(t) == make_vector(s, 3.36, 'x', 123))); + std::cout << reverse(reverse(t)) << std::endl; + BOOST_TEST((reverse(reverse(t)) == t)); + } + + return boost::report_errors(); +} + + diff --git a/test/algorithm/transform.cpp b/test/algorithm/transform.cpp new file mode 100644 index 00000000..e0cfdf34 --- /dev/null +++ b/test/algorithm/transform.cpp @@ -0,0 +1,91 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct square +{ + template + struct result + { + BOOST_STATIC_ASSERT(!boost::is_reference::value); + typedef int type; + }; + + template + int operator()(T x) const + { + return x * x; + } +}; + +struct add +{ + template + struct result + { + typedef int type; + }; + + template + int operator()(A a, B b) const + { + return a + b; + } +}; + +int +main() +{ + using namespace boost::fusion; + using boost::mpl::range_c; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing the transform + + { + typedef range_c sequence_type; + sequence_type sequence; + std::cout << transform(sequence, square()) << std::endl; + BOOST_TEST((transform(sequence, square()) == make_vector(25, 36, 49, 64))); + } + + { + typedef range_c mpl_list1; + std::cout << transform(mpl_list1(), square()) << std::endl; + BOOST_TEST((transform(mpl_list1(), square()) == make_vector(25, 36, 49, 64))); + } + + { + vector tup(1, 2, 3); + std::cout << transform(tup, square()) << std::endl; + BOOST_TEST((transform(tup, square()) == make_vector(1, 4, 9))); + } + + { + vector tup1(1, 2, 3); + vector tup2(4, 5, 6); + std::cout << transform(tup1, tup2, add()) << std::endl; + BOOST_TEST((transform(tup1, tup2, add()) == make_vector(5, 7, 9))); + } + + return boost::report_errors(); +} + diff --git a/test/algorithm/zip.cpp b/test/algorithm/zip.cpp new file mode 100644 index 00000000..bc403a53 --- /dev/null +++ b/test/algorithm/zip.cpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +int main() +{ + using namespace boost::fusion; + { + BOOST_TEST(zip(make_vector(1,2), make_vector('a','b')) == make_vector(make_vector(1,'a'), make_vector(2,'b'))); + BOOST_TEST( + zip( + make_vector(1,2), + make_vector('a','b'), + make_vector(-1,-2)) + == make_vector( + make_vector(1,'a',-1), + make_vector(2,'b',-2))); // Zip more than 2 sequences + } + return boost::report_errors(); +} diff --git a/test/sequence/array.cpp b/test/sequence/array.cpp new file mode 100644 index 00000000..b9144baa --- /dev/null +++ b/test/sequence/array.cpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +int main() +{ + using namespace boost::fusion; + typedef boost::array array_type; + + BOOST_MPL_ASSERT((traits::is_sequence)); + BOOST_MPL_ASSERT_NOT((traits::is_view)); + + array_type arr = {{1,2,3}}; + + BOOST_TEST(*begin(arr) == 1); + BOOST_TEST(*next(begin(arr)) == 2); + BOOST_TEST(*advance_c<2>(begin(arr)) == 3); + BOOST_TEST(prior(next(begin(arr))) == begin(arr)); + BOOST_TEST(*prior(end(arr)) == 3); + BOOST_TEST(at_c<2>(arr) == 3); + BOOST_TEST(size(arr) == 3); + BOOST_TEST(distance(begin(arr), end(arr)) == 3); + + return boost::report_errors(); +} diff --git a/test/sequence/as_list.cpp b/test/sequence/as_list.cpp new file mode 100644 index 00000000..d21da3c4 --- /dev/null +++ b/test/sequence/as_list.cpp @@ -0,0 +1,54 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + vector0 empty; + std::cout << as_list(make_vector(1, 1.23, "harru")) << std::endl; + std::cout << as_list(push_back(empty, 999)) << std::endl; + + BOOST_TEST(as_list(make_vector(1, 1.23, "harru")) == make_vector(1, 1.23, std::string("harru"))); + BOOST_TEST(as_list(push_back(empty, 999)) == push_back(empty, 999)); + } + + { + std::cout << as_list(mpl::vector_c()) << std::endl; + BOOST_TEST((as_list(mpl::vector_c()) + == mpl::vector_c())); + } + + { + // test conversion + list l(make_vector(123, "harru")); + BOOST_TEST(l == make_vector(123, "harru")); + l = (make_vector(235, "hola")); // test assign + BOOST_TEST(l == make_vector(235, "hola")); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/as_map.cpp b/test/sequence/as_map.cpp new file mode 100644 index 00000000..5b4fa6d7 --- /dev/null +++ b/test/sequence/as_map.cpp @@ -0,0 +1,62 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + vector0 empty; + std::cout << as_map(make_list(make_pair('X'), make_pair("Men"))) << std::endl; + std::cout << as_map(push_back(empty, make_pair(999))) << std::endl; + } + + { + typedef pair p1; + typedef pair p2; + result_of::as_map >::type map(make_pair('X'), make_pair("Men")); + std::cout << at_key(map) << std::endl; + std::cout << at_key(map) << std::endl; + BOOST_TEST(at_key(map) == 'X'); + BOOST_TEST(at_key(map) == "Men"); + } + + { + // test conversion + typedef map< + pair + , pair > + map_type; + + map_type m(make_vector(make_pair('X'), make_pair("Men"))); + BOOST_TEST(as_vector(m) == make_vector(make_pair('X'), make_pair("Men"))); + m = (make_vector(make_pair('X'), make_pair("Men"))); // test assign + BOOST_TEST(as_vector(m) == make_vector(make_pair('X'), make_pair("Men"))); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/as_set.cpp b/test/sequence/as_set.cpp new file mode 100644 index 00000000..2a093d9d --- /dev/null +++ b/test/sequence/as_set.cpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + vector0 empty; + std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl; + std::cout << as_set(push_back(empty, 999)) << std::endl; + + BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru"))) + == make_list(1, 1.23, std::string("harru"))); + BOOST_TEST(as_list(as_set(push_back(empty, 999))) + == push_back(empty, 999)); + } + + { + result_of::as_set >::type set(1, 1.23, "harru"); + std::cout << at_key(set) << std::endl; + BOOST_TEST(at_key(set) == 1); + } + + { + std::cout << as_set(mpl::vector_c()) << std::endl; + BOOST_TEST((as_list(as_set(mpl::vector_c())) + == mpl::vector_c())); + } + + { + // test conversion + set s(make_vector(123, "harru")); + BOOST_TEST(as_vector(s) == make_vector(123, "harru")); + s = (make_vector(235, "hola")); // test assign + BOOST_TEST(as_vector(s) == make_vector(235, "hola")); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/as_vector.cpp b/test/sequence/as_vector.cpp new file mode 100644 index 00000000..8360e2e0 --- /dev/null +++ b/test/sequence/as_vector.cpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + vector0 empty; + std::cout << as_vector(make_list(1, 1.23, "harru")) << std::endl; + std::cout << as_vector(push_back(empty, 999)) << std::endl; + + BOOST_TEST(as_vector(make_list(1, 1.23, "harru")) == make_list(1, 1.23, std::string("harru"))); + BOOST_TEST(as_vector(push_back(empty, 999)) == push_back(empty, 999)); + } + + { + std::cout << as_vector(mpl::vector_c()) << std::endl; + BOOST_TEST((as_vector(mpl::vector_c()) + == mpl::vector_c())); + } + + { + // test conversion + vector v(make_list(123, "harru")); + BOOST_TEST(v == make_list(123, "harru")); + v = (make_list(235, "hola")); // test assign + BOOST_TEST(v == make_list(235, "hola")); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/comparison.hpp b/test/sequence/comparison.hpp new file mode 100644 index 00000000..b7378c66 --- /dev/null +++ b/test/sequence/comparison.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +void +equality_test() +{ + using namespace boost::fusion; + + FUSION_SEQUENCE v1(5, 'a'); + FUSION_SEQUENCE v2(5, 'a'); + BOOST_TEST(v1 == v2); + + FUSION_SEQUENCE v3(5, 'b'); + FUSION_SEQUENCE t4(2, 'a'); + BOOST_TEST(v1 != v3); + BOOST_TEST(v1 != t4); + BOOST_TEST(!(v1 != v2)); + + FUSION_SEQUENCE v5(5, 'a', true); + BOOST_TEST(v1 != v5); + BOOST_TEST(!(v1 == v5)); + BOOST_TEST(v5 != v1); + BOOST_TEST(!(v5 == v1)); +} + +void +ordering_test() +{ + using namespace boost::fusion; + + FUSION_SEQUENCE v1(4, 3.3f); + FUSION_SEQUENCE v2(5, 3.3f); + FUSION_SEQUENCE v3(5, 4.4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + +#if defined(FUSION_TEST_FAIL) + FUSION_SEQUENCE v5(5, 'a', true); + v1 >= v5; +#endif +} + + + diff --git a/test/sequence/cons.cpp b/test/sequence/cons.cpp new file mode 100644 index 00000000..22a150f2 --- /dev/null +++ b/test/sequence/cons.cpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2005 Joel de Guzman + Copyright (c) 2005 Eric Niebler + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +int +main() +{ + using namespace boost::fusion; + using boost::is_same; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing cons + + { + std::string hello("hello"); + cons > ns = + make_cons(1, make_cons(hello)); + + BOOST_TEST((*begin(ns) == 1)); + BOOST_TEST((*next(begin(ns)) == hello)); + + *begin(ns) += 1; + *next(begin(ns)) += ' '; + + BOOST_TEST((*begin(ns) == 2)); + BOOST_TEST((*next(begin(ns)) == hello + ' ')); + + for_each(ns, boost::lambda::_1 += ' '); + + BOOST_TEST((*begin(ns) == 2 + ' ')); + BOOST_TEST((*next(begin(ns)) == hello + ' ' + ' ')); + } + + { + BOOST_TEST( + make_cons("hello") == make_vector(std::string("hello")) + ); + + BOOST_TEST( + make_cons(123, make_cons("hello")) == + make_vector(123, std::string("hello")) + ); + } + + { + vector t(1, 1.1f); + cons > nf = + make_cons(1, make_cons(1.1f)); + + BOOST_TEST((t == nf)); + BOOST_TEST((vector(1) == filter_if >(nf))); + + std::cout << nf << std::endl; + std::cout << filter_if >(nf) << std::endl; + } + + { + int i = 3; + cons tie(cons_tie(i)); + BOOST_TEST((*begin(tie) == 3)); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/construction.hpp b/test/sequence/construction.hpp new file mode 100644 index 00000000..da9e400a --- /dev/null +++ b/test/sequence/construction.hpp @@ -0,0 +1,110 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +namespace +{ + // something to prevent warnings for unused variables + template void dummy(const T&) {} + + // no public default constructor + class foo + { + public: + + explicit foo(int v) : val(v) {} + + bool operator==(const foo& other) const + { + return val == other.val; + } + + private: + + foo() {} + int val; + }; + + // another class without a public default constructor + class no_def_constructor + { + no_def_constructor() {} + + public: + + no_def_constructor(std::string) {} + }; +} + +inline void +test() +{ + using namespace boost::fusion; + + FUSION_SEQUENCE t1; + BOOST_TEST(FUSION_AT<0>(t1) == int()); + + FUSION_SEQUENCE t2(5.5f); + BOOST_TEST(FUSION_AT<0>(t2) > 5.4f && FUSION_AT<0>(t2) < 5.6f); + + FUSION_SEQUENCE t3(foo(12)); + BOOST_TEST(FUSION_AT<0>(t3) == foo(12)); + + FUSION_SEQUENCE t4(t2); + BOOST_TEST(FUSION_AT<0>(t4) > 5.4 && FUSION_AT<0>(t4) < 5.6); + + FUSION_SEQUENCE t5; + BOOST_TEST(FUSION_AT<0>(t5) == int()); + BOOST_TEST(FUSION_AT<1>(t5) == float()); + + FUSION_SEQUENCE t6(12, 5.5f); + BOOST_TEST(FUSION_AT<0>(t6) == 12); + BOOST_TEST(FUSION_AT<1>(t6) > 5.4f && FUSION_AT<1>(t6) < 5.6f); + + FUSION_SEQUENCE t7(t6); + BOOST_TEST(FUSION_AT<0>(t7) == 12); + BOOST_TEST(FUSION_AT<1>(t7) > 5.4f && FUSION_AT<1>(t7) < 5.6f); + + FUSION_SEQUENCE t8(t6); + BOOST_TEST(FUSION_AT<0>(t8) == 12); + BOOST_TEST(FUSION_AT<1>(t8) > 5.4f && FUSION_AT<1>(t8) < 5.6f); + + dummy + ( + FUSION_SEQUENCE( + std::string("Jaba"), // ok, since the default + std::string("Daba"), // constructor is not used + std::string("Doo") + ) + ); + + dummy(FUSION_SEQUENCE()); + dummy(FUSION_SEQUENCE(1,3.14)); + +#if defined(FUSION_TEST_FAIL) + dummy(FUSION_SEQUENCE()); // should fail, no defaults for references + dummy(FUSION_SEQUENCE()); // likewise +#endif + + { + double dd = 5; + dummy(FUSION_SEQUENCE(dd)); // ok + dummy(FUSION_SEQUENCE(dd+3.14)); // ok, but dangerous + } + +#if defined(FUSION_TEST_FAIL) + dummy(FUSION_SEQUENCE(dd+3.14)); // should fail, + // temporary to non-const reference +#endif +} diff --git a/test/sequence/copy.hpp b/test/sequence/copy.hpp new file mode 100644 index 00000000..665983c7 --- /dev/null +++ b/test/sequence/copy.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +#if !defined(FUSION_MAKE) +#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE) +#endif + +#if !defined(FUSION_TIE) +#define FUSION_TIE BOOST_PP_CAT(FUSION_SEQUENCE, _tie) +#endif + +namespace +{ + // classes with different kinds of conversions + class AA {}; + class BB : public AA {}; + struct CC { CC() {} CC(const BB&) {} }; + struct DD { operator CC() const { return CC(); }; }; +} + +void +test() +{ + using namespace boost::fusion; + + FUSION_SEQUENCE t1(4, 'a'); + FUSION_SEQUENCE t2(5, 'b'); + t2 = t1; + BOOST_TEST(FUSION_AT<0>(t1) == FUSION_AT<0>(t2)); + BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t2)); + + FUSION_SEQUENCE t3(2, "a"); + t3 = t1; + BOOST_TEST((double)FUSION_AT<0>(t1) == FUSION_AT<0>(t3)); + BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t3)[0]); + + // testing copy and assignment with implicit conversions + // between elements testing tie + + FUSION_SEQUENCE t; + FUSION_SEQUENCE a(t); + a = t; + + int i; char c; double d; + FUSION_TIE(i, c, d) = FUSION_MAKE(1, 'a', 5.5); + + BOOST_TEST(i==1); + BOOST_TEST(c=='a'); + BOOST_TEST(d>5.4 && d<5.6); +} diff --git a/test/sequence/filter_view.cpp b/test/sequence/filter_view.cpp new file mode 100644 index 00000000..7f365545 --- /dev/null +++ b/test/sequence/filter_view.cpp @@ -0,0 +1,118 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator char const*() const + { + return ""; + } +}; + +struct Y +{ + operator char const*() const + { + return ""; + } +}; + +struct reject_all +{ + template + struct apply : boost::mpl::false_ + {}; +}; + +int +main() +{ + using namespace boost::fusion; + + using boost::mpl::int_; + using boost::mpl::_; + using boost::mpl::not_; + using boost::mpl::less; + using boost::mpl::vector_c; + using boost::is_class; + using boost::is_same; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { // Testing the static find_if (internal function) + + typedef vector vector_type; + + vector_type v(1, 'x', 987654, X()); + typedef vector_iterator begin; + typedef vector_iterator end; + typedef detail::static_find_if > filter; + typedef filter::type type; + + BOOST_TEST(*type(v) == 987654); + std::cout << *type(v) << std::endl; + std::cout << *filter::call(begin(v)) << std::endl; + BOOST_TEST(*type(v) == *filter::call(begin(v))); + } + + { + typedef vector vector_type; + + X x; Y y; + vector_type v(y, '@', 987654, x, true, 6.6); + typedef filter_view > > filter_view_type; + filter_view_type view(v); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector('@', 987654, true, 6.6))); + BOOST_STATIC_ASSERT(result_of::size::value == 4); + } + + { + // $$$ JDG $$$ For some obscure reason, comeau 4.3.3 has problems with this. + // vc7.1 and g++ are ok. The errors from comeau are useless. + + typedef vector_c vector_type; + typedef filter_view > > filter_view_type; + vector_type v; + filter_view_type view(v); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(1, 2, 0, -1))); + BOOST_STATIC_ASSERT(result_of::size::value == 4); + } + + { + // Previous filtering out all values caused problems as begin was not equal to end + // Picked up by Andreas Pokorny + typedef vector vec; + typedef filter_view filter_view_type; + + BOOST_MPL_ASSERT((result_of::equal_to::type, result_of::end::type>)); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/io.cpp b/test/sequence/io.cpp new file mode 100644 index 00000000..3b101a53 --- /dev/null +++ b/test/sequence/io.cpp @@ -0,0 +1,117 @@ +/*============================================================================= + Copyright (C) 1999-2003 Jaakko Järvi + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined BOOST_NO_STRINGSTREAM +# include +#else +# include +#endif + +using boost::fusion::vector; +using boost::fusion::make_vector; +using boost::fusion::tuple_close; +using boost::fusion::tuple_open; +using boost::fusion::tuple_delimiter; + +#if defined BOOST_NO_STRINGSTREAM + using std::ostrstream; + using std::istrstream; + typedef ostrstream useThisOStringStream; + typedef istrstream useThisIStringStream; +#else + using std::ostringstream; + using std::istringstream; + typedef ostringstream useThisOStringStream; + typedef istringstream useThisIStringStream; +#endif + +using std::endl; +using std::ofstream; +using std::ifstream; +using std::string; + +int +main() +{ + using boost::fusion::tuple_close; + using boost::fusion::tuple_open; + using boost::fusion::tuple_delimiter; + + useThisOStringStream os1; + + // Set format [a, b, c] for os1 + os1 << tuple_open('['); + os1 << tuple_close(']'); + os1 << tuple_delimiter(','); + os1 << make_vector(1, 2, 3); + + BOOST_TEST (os1.str() == std::string("[1,2,3]") ); + + { + useThisOStringStream os2; + // Set format (a:b:c) for os2; + os2 << tuple_open('('); + os2 << tuple_close(')'); + os2 << tuple_delimiter(':'); + + os2 << make_vector("TUPU", "HUPU", "LUPU", 4.5); + BOOST_TEST (os2.str() == std::string("(TUPU:HUPU:LUPU:4.5)") ); + } + + // The format is still [a, b, c] for os1 + os1 << make_vector(1, 2, 3); + BOOST_TEST (os1.str() == std::string("[1,2,3][1,2,3]") ); + + std::ofstream tmp("temp.tmp"); + + tmp << make_vector("One", "Two", 3); + tmp << tuple_delimiter(':'); + tmp << make_vector(1000, 2000, 3000) << endl; + + tmp.close(); + + // When reading tuples from a stream, manipulators must be set correctly: + ifstream tmp3("temp.tmp"); + vector j; + + tmp3 >> j; + BOOST_TEST (tmp3.good() ); + + tmp3 >> tuple_delimiter(':'); + vector i; + tmp3 >> i; + BOOST_TEST (tmp3.good() ); + + tmp3.close(); + + // reading vector in format (a b c); + useThisIStringStream is("(100 200 300)"); + + vector ti; + BOOST_TEST(bool((is >> ti) != 0)); + BOOST_TEST(ti == make_vector(100, 200, 300)); + + // Note that strings are problematic: + // writing a tuple on a stream and reading it back doesn't work in + // general. If this is wanted, some kind of a parseable string class + // should be used. + + return boost::report_errors(); +} + diff --git a/test/sequence/iterator.hpp b/test/sequence/iterator.hpp new file mode 100644 index 00000000..629f9bfc --- /dev/null +++ b/test/sequence/iterator.hpp @@ -0,0 +1,198 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void test() +{ + using namespace boost::fusion; + using namespace boost; + + { // Testing deref, next, prior, begin, end + + char const* s = "Hello"; + typedef FUSION_SEQUENCE seq_type; + seq_type v(1, 'x', 3.3, s); + result_of::begin::type i(v); + + BOOST_TEST(*i == 1); + BOOST_TEST(*next(i) == 'x'); + BOOST_TEST(*next(next(i)) == 3.3); + BOOST_TEST(*next(next(next(i))) == s); + next(next(next(next(i)))); // end + +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*prior(next(next(next(i)))) == 3.3); + BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x'); + BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1); +#endif + BOOST_TEST(*begin(v) == 1); +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*prior(end(v)) == s); +#endif + + *i = 3; + BOOST_TEST(*i == 3); + BOOST_TEST(&*i == &at_c<0>(v)); + + // prove that it is mutable + *i = 987; + BOOST_TEST(*i == 987); + } + + { // Testing const sequence and const iterator + + char const* s = "Hello"; + typedef FUSION_SEQUENCE const seq_type; + seq_type t(1, 'x', 3.3, s); + result_of::begin::type i(t); + + BOOST_TEST(*i == 1); + BOOST_TEST(*next(i) == 'x'); + BOOST_TEST(*begin(t) == 1); +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*prior(end(t)) == s); +#endif + +#ifdef FUSION_TEST_FAIL + *i = 3; // must not compile +#endif + } + + { // Testing iterator equality + + typedef FUSION_SEQUENCE seq_type; + typedef FUSION_SEQUENCE const cseq_type; + typedef result_of::begin::type vi1; + typedef result_of::begin::type vi2; + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + BOOST_STATIC_ASSERT((result_of::equal_to::value)); + } + + { + typedef FUSION_SEQUENCE seq_type; + typedef result_of::begin::type begin_type; + typedef result_of::end::type end_type; + typedef result_of::next::type i1; + typedef result_of::next::type i2; + + BOOST_STATIC_ASSERT((is_same::value)); + } + + { // testing deref, next, prior, begin, end + + char const* s = "Hello"; + typedef FUSION_SEQUENCE seq_type; + seq_type t(1, 'x', 3.3, s); + result_of::begin::type i(t); + + BOOST_TEST(*i == 1); + BOOST_TEST(*next(i) == 'x'); + BOOST_TEST(*next(next(i)) == 3.3); + BOOST_TEST(*next(next(next(i))) == s); + + next(next(next(next(i)))); // end + +#ifdef FUSION_TEST_FAIL + next(next(next(next(next(i))))); // past the end: must not compile +#endif + +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*prior(next(next(next(i)))) == 3.3); + BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x'); + BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1); +#endif + BOOST_TEST(*begin(t) == 1); +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*prior(end(t)) == s); +#endif + + *i = 3; + BOOST_TEST(*i == 3); + BOOST_TEST(*i == at_c<0>(t)); + } + + { // Testing distance + + typedef FUSION_SEQUENCE seq_type; + seq_type t(1, 'x', 3.3, "Hello"); + + BOOST_STATIC_ASSERT((result_of::distance< + result_of::begin::type + , result_of::end::type >::value == 4)); + + BOOST_TEST(distance(begin(t), end(t)).value == 4); + } + + { // Testing tuple iterator result_of::value_of, result_of::deref, result_of::value_at + + typedef FUSION_SEQUENCE seq_type; + typedef result_of::begin::type i0; + typedef result_of::next::type i1; + typedef result_of::next::type>::type i2; + + BOOST_STATIC_ASSERT(( + is_same::type, int>::value)); + + BOOST_STATIC_ASSERT(( + is_same::type, char&>::value)); + + BOOST_STATIC_ASSERT(( + is_same::type, FUSION_TRAVERSAL_TAG>::value)); + + BOOST_STATIC_ASSERT((is_same::type, int&>::value)); + BOOST_STATIC_ASSERT((is_same::type, char&>::value)); + + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, char&>::value)); + } + + { // Testing advance + + typedef FUSION_SEQUENCE seq_type; + seq_type t(1, 'x', 3.3, "Hello"); + + BOOST_TEST(*advance_c<0>(begin(t)) == at_c<0>(t)); + BOOST_TEST(*advance_c<1>(begin(t)) == at_c<1>(t)); + BOOST_TEST(*advance_c<2>(begin(t)) == at_c<2>(t)); + BOOST_TEST(*advance_c<3>(begin(t)) == at_c<3>(t)); + +#if !defined(FUSION_NO_PRIOR) + BOOST_TEST(*advance_c<-1>(end(t)) == at_c<3>(t)); + BOOST_TEST(*advance_c<-2>(end(t)) == at_c<2>(t)); + BOOST_TEST(*advance_c<-3>(end(t)) == at_c<1>(t)); + BOOST_TEST(*advance_c<-4>(end(t)) == at_c<0>(t)); +#endif + + BOOST_TEST(&*advance_c<0>(begin(t)) == &at_c<0>(t)); + BOOST_TEST(&*advance_c<1>(begin(t)) == &at_c<1>(t)); + BOOST_TEST(&*advance_c<2>(begin(t)) == &at_c<2>(t)); + BOOST_TEST(&*advance_c<3>(begin(t)) == &at_c<3>(t)); + } +} + + + + diff --git a/test/sequence/iterator_range.cpp b/test/sequence/iterator_range.cpp new file mode 100644 index 00000000..dd1131be --- /dev/null +++ b/test/sequence/iterator_range.cpp @@ -0,0 +1,82 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + char const* s = "Ruby"; + typedef vector vector_type; + vector_type vec(1, 'x', 3.3, s); + + { + typedef vector_iterator i1t; + typedef vector_iterator i3t; + + i1t i1(vec); + i3t i3(vec); + + typedef iterator_range slice_t; + slice_t slice(i1, i3); + std::cout << slice << std::endl; + BOOST_TEST((slice == make_vector('x', 3.3))); + BOOST_STATIC_ASSERT(result_of::size::value == 2); + } + + { + typedef vector_iterator i1t; + typedef vector_iterator i3t; + + i1t i1(vec); + i3t i3(vec); + + typedef iterator_range slice_t; + slice_t slice(i1, i3); + std::cout << slice << std::endl; + BOOST_TEST(slice == make_vector()); + BOOST_STATIC_ASSERT(result_of::size::value == 0); + } + } + + { + typedef boost::mpl::vector_c mpl_vec; + typedef boost::mpl::begin::type it0; + typedef boost::mpl::next::type it1; + typedef boost::mpl::next::type it2; + typedef boost::mpl::next::type it3; + + it1 f; + it3 l; + + typedef iterator_range slice_t; + slice_t slice(f, l); + std::cout << slice << std::endl; + BOOST_TEST((slice == make_vector(3, 4))); + BOOST_STATIC_ASSERT(result_of::size::value == 2); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/joint_view.cpp b/test/sequence/joint_view.cpp new file mode 100644 index 00000000..3457f076 --- /dev/null +++ b/test/sequence/joint_view.cpp @@ -0,0 +1,145 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include + +struct X +{ + operator char const*() const + { + return ""; + } +}; + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing joint_view + + { + vector t1(3); + vector t2; + typedef joint_view, vector > view_type; + view_type view(t1, t2); + + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(3, X()))); + } + + { + vector t1(3, 'x'); + vector t2; + typedef joint_view, vector > view_type; + view_type view(t1, t2); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(3, 'x', X()))); + + *begin(view) = 4; + BOOST_TEST(at_c<0>(t1) == 4); + } + + { + vector t1(3, 'x'); + vector t2; + typedef joint_view, vector > view_type; + view_type view(t1, t2); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(3, 'x', X(), 0))); + } + + { + typedef vector t1_type; + t1_type t1(777); + typedef vector t2_type; + t2_type t2(1, 'x', 3.3); + + { + typedef joint_view view_type; + view_type view(t1, t2); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(777, 1, 'x', 3.3))); + } + + { + typedef joint_view view_type; + view_type view(t2, t1); + std::cout << view << std::endl; + BOOST_TEST((view == make_vector(1, 'x', 3.3, 777))); + } + + { + typedef joint_view jv_type; + typedef joint_view jv2_type; + + jv_type jv(t2, t1); + jv2_type jv2(jv, jv); + + std::cout << jv << std::endl; + std::cout << jv2 << std::endl; + + BOOST_TEST(jv2 + == make_vector(1, 'x', 3.3, 777, 1, 'x', 3.3, 777)); + } + + { + typedef joint_view jt_type; + typedef joint_view jv2_type; + typedef joint_view jv3_type; + + jt_type jt(t2, t1); + jv2_type jv2(t1, t2); + jv3_type jv3(jt, jv2); + + std::cout << jt << std::endl; + std::cout << jv2 << std::endl; + std::cout << jv3 << std::endl; + + BOOST_TEST(jv3 + == make_vector(1, 'x', 3.3, 777, 777, 1, 'x', 3.3)); + } + + { + typedef joint_view, t1_type> jt_type; + vector<> empty; + jt_type jt(empty, t1); + std::cout << jt << std::endl; + BOOST_TEST(jt == make_vector(777)); + } + + { + typedef joint_view > jt_type; + vector<> empty; + jt_type jt(t1, empty); + std::cout << jt << std::endl; + BOOST_TEST(jt == make_vector(777)); + } + + { + typedef joint_view, vector<> > jt_type; + vector<> empty; + jt_type jt(empty, empty); + std::cout << jt << std::endl; + BOOST_TEST(jt == make_vector()); + } + } + + return boost::report_errors(); +} + diff --git a/test/sequence/list_comparison.cpp b/test/sequence/list_comparison.cpp new file mode 100644 index 00000000..402bf704 --- /dev/null +++ b/test/sequence/list_comparison.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE list +#include "comparison.hpp" + +int +main() +{ + equality_test(); + ordering_test(); + return boost::report_errors(); +} diff --git a/test/sequence/list_construction.cpp b/test/sequence/list_construction.cpp new file mode 100644 index 00000000..fb412f16 --- /dev/null +++ b/test/sequence/list_construction.cpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE list +#include "construction.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} diff --git a/test/sequence/list_copy.cpp b/test/sequence/list_copy.cpp new file mode 100644 index 00000000..673b1c42 --- /dev/null +++ b/test/sequence/list_copy.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include + +#define FUSION_SEQUENCE list +#include "copy.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/list_iterator.cpp b/test/sequence/list_iterator.cpp new file mode 100644 index 00000000..20e04383 --- /dev/null +++ b/test/sequence/list_iterator.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE list +#define FUSION_NO_PRIOR +#define FUSION_TRAVERSAL_TAG forward_traversal_tag +#include "./iterator.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + + + diff --git a/test/sequence/list_make.cpp b/test/sequence/list_make.cpp new file mode 100644 index 00000000..03919708 --- /dev/null +++ b/test/sequence/list_make.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE list +#include "make.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/list_misc.cpp b/test/sequence/list_misc.cpp new file mode 100644 index 00000000..c6ea3149 --- /dev/null +++ b/test/sequence/list_misc.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE list +#define FUSION_FORWARD_ONLY +#include "misc.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/list_mutate.cpp b/test/sequence/list_mutate.cpp new file mode 100644 index 00000000..fac31fb5 --- /dev/null +++ b/test/sequence/list_mutate.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE list +#include "mutate.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/list_tie.cpp b/test/sequence/list_tie.cpp new file mode 100644 index 00000000..950b75a7 --- /dev/null +++ b/test/sequence/list_tie.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include + +#define FUSION_SEQUENCE list +#include "tie.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/list_value_at.cpp b/test/sequence/list_value_at.cpp new file mode 100644 index 00000000..47347d69 --- /dev/null +++ b/test/sequence/list_value_at.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE list +#include "value_at.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/make.hpp b/test/sequence/make.hpp new file mode 100644 index 00000000..1b175811 --- /dev/null +++ b/test/sequence/make.hpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +#if !defined(FUSION_MAKE) +#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE) +#endif + +namespace +{ + // something to prevent warnings for unused variables + template void dummy(const T&) {} + + class A {}; + class B {}; +} + +void make_tuple_test() {} + +void +test() +{ + using namespace boost::fusion; + + { + FUSION_SEQUENCE t1 = FUSION_MAKE(5, 'a'); + BOOST_TEST(FUSION_AT<0>(t1) == 5); + BOOST_TEST(FUSION_AT<1>(t1) == 'a'); + + FUSION_SEQUENCE t2; + t2 = FUSION_MAKE((short int)2, std::string("Hi")); + BOOST_TEST(FUSION_AT<0>(t2) == 2); + BOOST_TEST(FUSION_AT<1>(t2) == "Hi"); + } + + { // This test was previously disallowed for non-PTS compilers. + A a = A(); B b; + const A ca = a; + FUSION_MAKE(boost::cref(a), b); + FUSION_MAKE(boost::ref(a), b); + FUSION_MAKE(boost::ref(a), boost::cref(b)); + FUSION_MAKE(boost::ref(ca)); + } + + { // the result of make_xxx is assignable: + BOOST_TEST(FUSION_MAKE(2, 4, 6) == + (FUSION_MAKE(1, 2, 3) = FUSION_MAKE(2, 4, 6))); + } + + { // This test was previously disallowed for non-PTS compilers. + FUSION_MAKE("Donald", "Daisy"); // should work; + // std::make_pair("Doesn't","Work"); // fails + } + + { + // You can store a reference to a function in a sequence + FUSION_SEQUENCE adf(make_tuple_test); + dummy(adf); // avoid warning for unused variable + } + +#if defined(FUSION_TEST_FAIL) + { + // But make_xxx doesn't work + // with function references, since it creates a const + // qualified function type + + FUSION_MAKE(make_tuple_test); + } +#endif + + { + // With function pointers, make_xxx works just fine + FUSION_MAKE(&make_tuple_test); + } +} diff --git a/test/sequence/make_list.cpp b/test/sequence/make_list.cpp new file mode 100644 index 00000000..03919708 --- /dev/null +++ b/test/sequence/make_list.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE list +#include "make.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/make_vector.cpp b/test/sequence/make_vector.cpp new file mode 100644 index 00000000..ff80e84c --- /dev/null +++ b/test/sequence/make_vector.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE vector +#include "make.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/map.cpp b/test/sequence/map.cpp new file mode 100644 index 00000000..93ce92a7 --- /dev/null +++ b/test/sequence/map.cpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + using namespace std; + using boost::fusion::pair; + using boost::fusion::make_pair; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + typedef map< + pair + , pair > + map_type; + + BOOST_MPL_ASSERT((traits::is_associative)); + + map_type m( + make_pair('X') + , make_pair("Men")); + + std::cout << at_key(m) << std::endl; + std::cout << at_key(m) << std::endl; + + BOOST_TEST(at_key(m) == 'X'); + BOOST_TEST(at_key(m) == "Men"); + + BOOST_STATIC_ASSERT(( + boost::is_same::type, char>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::type, std::string>::value)); + + std::cout << m << std::endl; + + BOOST_STATIC_ASSERT((result_of::has_key::value)); + BOOST_STATIC_ASSERT((result_of::has_key::value)); + BOOST_STATIC_ASSERT((!result_of::has_key::value)); + } + + { + std::cout << make_map('X', 123) << std::endl; + BOOST_TEST(at_key(make_map('X', 123)) == 'X'); + BOOST_TEST(at_key(make_map('X', 123)) == 123); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/misc.hpp b/test/sequence/misc.hpp new file mode 100644 index 00000000..279c91ee --- /dev/null +++ b/test/sequence/misc.hpp @@ -0,0 +1,189 @@ +/*============================================================================= + Copyright (C) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +#if !defined(FUSION_SIZE) +#define FUSION_SIZE result_of::size +#endif + +template +struct is_same +{ +}; + +struct test_intrinsics1 +{ + // test at, begin, end, next, prior, advance, size, deref, etc. + + typedef boost::fusion::FUSION_SEQUENCE sequence; + typedef boost::mpl::begin::type first; + typedef boost::mpl::next::type second; + typedef boost::mpl::next::type third; + typedef boost::mpl::next::type fourth; + typedef boost::mpl::end::type last; + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, int>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, float>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, bool>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, char>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::at_c::type, bool>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::front::type, int>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref< + boost::mpl::advance_c::type>::type, char>::value)); + + BOOST_STATIC_ASSERT((boost::mpl::size::value == 4)); + BOOST_STATIC_ASSERT(!(boost::mpl::empty::value)); + BOOST_STATIC_ASSERT((boost::mpl::distance::value == 2)); + +#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev + + typedef boost::mpl::prior::type fourth_; + typedef boost::mpl::prior::type third_; + typedef boost::mpl::prior::type second_; + typedef boost::mpl::prior::type first_; + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, int>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, float>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, bool>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::deref::type, char>::value)); + + BOOST_STATIC_ASSERT((boost::is_same< + boost::mpl::back::type, char>::value)); + +#endif +}; + +struct test_intrinsics2 +{ + typedef boost::fusion::FUSION_SEQUENCE<> seq0; + +#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev + + typedef boost::fusion::FUSION_SEQUENCE target1; + typedef boost::mpl::push_back::type seq1; + BOOST_STATIC_ASSERT((boost::mpl::equal::value)); + + typedef boost::fusion::FUSION_SEQUENCE target2; + typedef boost::mpl::push_back::type seq2; + BOOST_STATIC_ASSERT((boost::mpl::equal::value)); + +#endif + + typedef boost::fusion::FUSION_SEQUENCE target3; + typedef boost::mpl::push_front::type seq3; + BOOST_STATIC_ASSERT((boost::mpl::equal::value)); + + typedef boost::fusion::FUSION_SEQUENCE target4; + typedef boost::mpl::push_front::type seq4; + BOOST_STATIC_ASSERT((boost::mpl::equal::value)); +}; + +void +test() +{ + using namespace boost::fusion; + + { // testing const sequences + + const FUSION_SEQUENCE t1(5, 3.3f); + BOOST_TEST(FUSION_AT<0>(t1) == 5); + BOOST_TEST(FUSION_AT<1>(t1) == 3.3f); + } + + { // testing at works with MPL integral constants + const FUSION_SEQUENCE t1(101, 'z'); + BOOST_TEST(boost::fusion::at >(t1) == 101); + BOOST_TEST(boost::fusion::at >(t1) == 'z'); + // explicitly try something other than mpl::int_ + BOOST_TEST((boost::fusion::at >(t1) == 101)); + BOOST_TEST((boost::fusion::at >(t1) == 'z')); + } + + { // testing size & empty + + typedef FUSION_SEQUENCE t1; + typedef FUSION_SEQUENCE<> t2; + + BOOST_STATIC_ASSERT(FUSION_SIZE::value == 3); + BOOST_STATIC_ASSERT(FUSION_SIZE::value == 0); + BOOST_STATIC_ASSERT(!result_of::empty::value); + BOOST_STATIC_ASSERT(result_of::empty::value); + } + + { // testing front & back + + typedef FUSION_SEQUENCE tup; + tup t(1, 2.2, "Kimpo"); + + BOOST_TEST(front(t) == 1); +#if !defined(FUSION_FORWARD_ONLY) // list has no back + BOOST_TEST(back(t) == "Kimpo"); +#endif + } + + { // testing is_sequence + + typedef FUSION_SEQUENCE t1; + typedef FUSION_SEQUENCE<> t2; + typedef FUSION_SEQUENCE t3; + + BOOST_STATIC_ASSERT(traits::is_sequence::value); + BOOST_STATIC_ASSERT(traits::is_sequence::value); + BOOST_STATIC_ASSERT(traits::is_sequence::value); + BOOST_STATIC_ASSERT(!traits::is_sequence::value); + BOOST_STATIC_ASSERT(!traits::is_sequence::value); + } + + { // testing mpl compatibility + + // test begin, end, next, prior, advance, size, deref, etc. + //~ typedef FUSION_SEQUENCE tuple_type; + //~ test_intrinsics1 test1; + //~ (void)test1; // prevent unused variable warning + + // test an algorithm + typedef FUSION_SEQUENCE t1; + typedef boost::mpl::find::type iter; + typedef boost::mpl::deref::type type; + BOOST_STATIC_ASSERT((boost::is_same::value)); + + } +} diff --git a/test/sequence/mutate.hpp b/test/sequence/mutate.hpp new file mode 100644 index 00000000..d1cd66df --- /dev/null +++ b/test/sequence/mutate.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +namespace +{ + // no public default constructor + class foo + { + public: + + explicit foo(int v) : val(v) {} + + bool operator==(const foo& other) const + { + return val == other.val; + } + + private: + + foo() {} + int val; + }; +} + +void +test() +{ + using namespace boost::fusion; + + FUSION_SEQUENCE t1(5, 12.2f, true, foo(4)); + FUSION_AT<0>(t1) = 6; + FUSION_AT<1>(t1) = 2.2f; + FUSION_AT<2>(t1) = false; + FUSION_AT<3>(t1) = foo(5); + + BOOST_TEST(FUSION_AT<0>(t1) == 6); + BOOST_TEST(FUSION_AT<1>(t1) > 2.1f && FUSION_AT<1>(t1) < 2.3f); + BOOST_TEST(FUSION_AT<2>(t1) == false); + BOOST_TEST(FUSION_AT<3>(t1) == foo(5)); +} diff --git a/test/sequence/reverse_view.cpp b/test/sequence/reverse_view.cpp new file mode 100644 index 00000000..50b445b7 --- /dev/null +++ b/test/sequence/reverse_view.cpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing the reverse_view + + { + typedef boost::mpl::range_c mpl_list1; + mpl_list1 l; + reverse_view rev(l); + + std::cout << rev << std::endl; + BOOST_TEST((rev == make_vector(8, 7, 6, 5))); + } + + { + char const* s = "Hi Kim"; + typedef vector vector_type; + vector_type t(123, 'x', 123456789, s); + typedef reverse_view view_type; + view_type rev(t); + + std::cout << rev << std::endl; + BOOST_TEST((rev == make_vector(s, 123456789, 'x', 123))); + + typedef result_of::begin::type first_type; + first_type first_it(begin(rev)); + typedef result_of::next::type second_type; + second_type second_it(next(first_it)); + BOOST_TEST((*second_it == 123456789)); + BOOST_TEST((*prior(second_it) == s)); + BOOST_TEST((*advance_c<2>(first_it) == 'x')); + BOOST_TEST((distance(first_it, second_it) == 1)); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/set.cpp b/test/sequence/set.cpp new file mode 100644 index 00000000..3a10a77f --- /dev/null +++ b/test/sequence/set.cpp @@ -0,0 +1,68 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + using namespace std; + using boost::fusion::pair; + using boost::fusion::make_pair; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + typedef set set_type; + + BOOST_MPL_ASSERT((traits::is_associative)); + + set_type m(123, "Hola"); + + std::cout << at_key(m) << std::endl; + std::cout << at_key(m) << std::endl; + + BOOST_TEST(at_key(m) == 123); + BOOST_TEST(at_key(m) == "Hola"); + + BOOST_STATIC_ASSERT(( + boost::is_same::type, int>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::type, std::string>::value)); + + std::cout << m << std::endl; + + BOOST_STATIC_ASSERT((result_of::has_key::value)); + BOOST_STATIC_ASSERT((result_of::has_key::value)); + BOOST_STATIC_ASSERT((!result_of::has_key::value)); + } + + { + std::cout << make_set('X', 123) << std::endl; + BOOST_TEST(at_key(make_set('X', 123)) == 'X'); + BOOST_TEST(at_key(make_set('X', 123)) == 123); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/single_view.cpp b/test/sequence/single_view.cpp new file mode 100644 index 00000000..6aec1d8b --- /dev/null +++ b/test/sequence/single_view.cpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include + +struct X {}; + +template +OS& operator<<(OS& os, X const&) +{ + os << ""; + return os; +} + +void foo() {} + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + single_view view1(3); + std::cout << view1 << std::endl; + +#ifdef FUSION_TEST_FAIL + // single_view is immutable + *begin(view1) += 4; +#endif + std::cout << view1 << std::endl; + BOOST_TEST(*begin(view1) == 3); + BOOST_TEST(view1.val == 3); + + single_view view2; + std::cout << view2 << std::endl; + } + + { + std::cout << make_single_view(1) << std::endl; + std::cout << make_single_view("Hello, World") << std::endl; + std::cout << make_single_view(&foo) << std::endl; + } + + return boost::report_errors(); +} + diff --git a/test/sequence/std_pair.cpp b/test/sequence/std_pair.cpp new file mode 100644 index 00000000..2f8536a2 --- /dev/null +++ b/test/sequence/std_pair.cpp @@ -0,0 +1,92 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + using namespace std; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + typedef std::pair pair_type; + BOOST_MPL_ASSERT_NOT((traits::is_view)); + pair_type p(123, "Hola!!!"); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, "Hola!!!")); + + at_c<0>(p) = 6; + at_c<1>(p) = "mama mia"; + BOOST_TEST(p == make_vector(6, "mama mia")); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == "mama mia"); + } + + { + fusion::vector v1(4, 3.3f); + std::pair v2(5, 3.3f); + fusion::vector v3(5, 4.4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from pair to vector + fusion::vector v(std::make_pair(123, "Hola!!!")); + v = std::make_pair(123, "Hola!!!"); + } + + { + // conversion from pair to list + fusion::list l(std::make_pair(123, "Hola!!!")); + l = std::make_pair(123, "Hola!!!"); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/tie.hpp b/test/sequence/tie.hpp new file mode 100644 index 00000000..a36c3985 --- /dev/null +++ b/test/sequence/tie.hpp @@ -0,0 +1,85 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +#if !defined(FUSION_MAKE) +#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE) +#endif + +#if !defined(FUSION_TIE) +#define FUSION_TIE BOOST_PP_CAT(FUSION_SEQUENCE, _tie) +#endif + +namespace +{ + // something to prevent warnings for unused variables + template void dummy(const T&) {} + + // no public default constructor + class foo + { + public: + + explicit foo(int v) : val(v) {} + + bool operator==(const foo& other) const + { + return val == other.val; + } + + private: + + foo() {} + int val; + }; +} + +void +test() +{ + using namespace boost::fusion; + + int a; + char b; + foo c(5); + + FUSION_TIE(a, b, c) = FUSION_MAKE(2, 'a', foo(3)); + BOOST_TEST(a == 2); + BOOST_TEST(b == 'a'); + BOOST_TEST(c == foo(3)); + + FUSION_TIE(a, ignore, c) = FUSION_MAKE((short int)5, false, foo(5)); + BOOST_TEST(a == 5); + BOOST_TEST(b == 'a'); + BOOST_TEST(c == foo(5)); + + int i, j; + FUSION_TIE(i, j) = FUSION_MAKE(1, 2); + BOOST_TEST(i == 1 && j == 2); + + FUSION_SEQUENCE ta; + +#if defined(FUSION_TEST_FAIL) + ta = std::FUSION_MAKE(1, 2); // should fail, tuple is of length 3, not 2 +#endif + + dummy(ta); + + // ties cannot be rebound + int d = 3; + FUSION_SEQUENCE ti(a); + BOOST_TEST(&FUSION_AT<0>(ti) == &a); + ti = FUSION_SEQUENCE(d); + BOOST_TEST(&FUSION_AT<0>(ti) == &a); +} diff --git a/test/sequence/transform_view.cpp b/test/sequence/transform_view.cpp new file mode 100644 index 00000000..554ac00f --- /dev/null +++ b/test/sequence/transform_view.cpp @@ -0,0 +1,102 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct square +{ + template + struct result + { + typedef int type; + }; + + template + int operator()(T x) const + { + return x * x; + } +}; + +struct add +{ + template + struct result + { + typedef int type; + }; + + template + int operator()(A a, B b) const + { + return a + b; + } +}; + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + +/// Testing the transform_view + + { + typedef boost::mpl::range_c sequence_type; + sequence_type sequence; + square sq; + typedef transform_view xform_type; + xform_type xform(sequence, sq); + + std::cout << xform << std::endl; + BOOST_TEST((xform == make_vector(25, 36, 49, 64))); + + typedef boost::fusion::result_of::begin::type first_type; + first_type first_it(boost::fusion::begin(xform)); + + typedef boost::fusion::result_of::next::type next_type; + next_type next_it(boost::fusion::next(first_it)); + BOOST_TEST((*next_it == 36)); + BOOST_TEST((*boost::fusion::prior(next_it) == 25)); + BOOST_TEST((boost::fusion::distance(first_it, next_it) == 1)); + + BOOST_TEST((*boost::fusion::advance_c<3>(boost::fusion::begin(xform)) == 64)); + } + + { + typedef boost::mpl::range_c sequence1_type; + typedef boost::mpl::range_c sequence2_type; + sequence1_type sequence1; + sequence2_type sequence2; + add f; + typedef transform_view xform_type; + xform_type xform(sequence1, sequence2, f); + + std::cout << xform << std::endl; + BOOST_TEST((xform == make_vector(15, 17, 19, 21))); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_comparison.cpp b/test/sequence/tuple_comparison.cpp new file mode 100644 index 00000000..3a98b28a --- /dev/null +++ b/test/sequence/tuple_comparison.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE tuple +#include "comparison.hpp" + +int +main() +{ + equality_test(); + ordering_test(); + return boost::report_errors(); +} diff --git a/test/sequence/tuple_construction.cpp b/test/sequence/tuple_construction.cpp new file mode 100644 index 00000000..888a5cd4 --- /dev/null +++ b/test/sequence/tuple_construction.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#include "construction.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} diff --git a/test/sequence/tuple_copy.cpp b/test/sequence/tuple_copy.cpp new file mode 100644 index 00000000..fc9a100a --- /dev/null +++ b/test/sequence/tuple_copy.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#define FUSION_MAKE make_tuple +#define FUSION_TIE tie +#include "copy.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_element.cpp b/test/sequence/tuple_element.cpp new file mode 100644 index 00000000..cf61f953 --- /dev/null +++ b/test/sequence/tuple_element.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#define FUSION_VALUE_AT(S, N) tuple_element +#include "value_at.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_make.cpp b/test/sequence/tuple_make.cpp new file mode 100644 index 00000000..e8dcbbfb --- /dev/null +++ b/test/sequence/tuple_make.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#define FUSION_MAKE make_tuple +#include "make.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_misc.cpp b/test/sequence/tuple_misc.cpp new file mode 100644 index 00000000..3945dcbc --- /dev/null +++ b/test/sequence/tuple_misc.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#define FUSION_SIZE tuple_size +#include "misc.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_mutate.cpp b/test/sequence/tuple_mutate.cpp new file mode 100644 index 00000000..ba72edbc --- /dev/null +++ b/test/sequence/tuple_mutate.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#include "mutate.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/tuple_tie.cpp b/test/sequence/tuple_tie.cpp new file mode 100644 index 00000000..85c69d96 --- /dev/null +++ b/test/sequence/tuple_tie.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE tuple +#define FUSION_AT get +#define FUSION_MAKE make_tuple +#define FUSION_TIE tie +#include "tie.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/unpack_args.cpp b/test/sequence/unpack_args.cpp new file mode 100644 index 00000000..d3249408 --- /dev/null +++ b/test/sequence/unpack_args.cpp @@ -0,0 +1,228 @@ +// +// Copyright (c) 2006 João Abecasis +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#include +#include +#include +#include +#include +#include + +namespace fusion = boost::fusion; + +//////////////////////////////////////////////////////////////////////////////// +// +// Helper stuff +// + +struct object {}; +struct nc_object : boost::noncopyable {}; + +template +inline T const & const_(T const & t) +{ + return t; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Test functoids +// + +// polymorphic functors +struct foo +{ + typedef int result_type; + + int operator()() { return 0; } + int operator()() const { return 1; } + + int operator()(int i) { return 2 + i; } + int operator()(int i) const { return 3 + i; } + + int operator()(int i, object &) { return 4 + i; } + int operator()(int i, object &) const { return 5 + i; } + int operator()(int i, object const &) { return 6 + i; } + int operator()(int i, object const &) const { return 7 + i; } + + int operator()(int i, object &, nc_object &) { return 10 + i; } + int operator()(int i, object &, nc_object &) const { return 11 + i; } +}; + +struct nc_foo + : boost::noncopyable +{ + typedef int result_type; + + int operator()() { return 0; } + int operator()() const { return 1; } + + int operator()(int i) { return 2 + i; } + int operator()(int i) const { return 3 + i; } +}; + +// nullary function +int bar() { return 20; } + +// unary function +int square(int i) { return i * i; } + +// binary functions +int baz1(int i, object &) { return 30 + i; } +int baz2(int i, object const &) { return 70 + i; } + +// cv-qualified unary function pointers +typedef int (* func_ptr)(int); +typedef int (* const c_func_ptr)(int); +typedef int (* volatile v_func_ptr)(int); +typedef int (* const volatile cv_func_ptr)(int); + + func_ptr func_ptr1 = □ + c_func_ptr func_ptr2 = □ + v_func_ptr func_ptr3 = □ +cv_func_ptr func_ptr4 = □ + +//////////////////////////////////////////////////////////////////////////////// +// +// Test data +// + +typedef int element1_type; +typedef object element2_type; +typedef nc_object & element3_type; + +int element1 = 100; +object element2 = object(); +nc_object element3; + +//////////////////////////////////////////////////////////////////////////////// +// +// Tests (by sequence size) +// + +template +void test_sequence_n(Sequence & seq, boost::mpl::int_<0>) +{ + { + foo f; + + BOOST_TEST( f () == fusion::unpack_args( f , seq )); + BOOST_TEST(const_(f)() == fusion::unpack_args(const_(f), seq )); + BOOST_TEST( f () == fusion::unpack_args( f , const_(seq))); + BOOST_TEST(const_(f)() == fusion::unpack_args(const_(f), const_(seq))); + } + + { + nc_foo nc_f; + + BOOST_TEST( nc_f () == fusion::unpack_args( nc_f , seq )); + BOOST_TEST(const_(nc_f)() == fusion::unpack_args(const_(nc_f), seq )); + BOOST_TEST( nc_f () == fusion::unpack_args( nc_f , const_(seq))); + BOOST_TEST(const_(nc_f)() == fusion::unpack_args(const_(nc_f), const_(seq))); + } + + BOOST_TEST(bar() == fusion::unpack_args(bar, seq)); +} + +template +void test_sequence_n(Sequence & seq, boost::mpl::int_<1>) +{ + { + foo f; + + BOOST_TEST( f (element1) == fusion::unpack_args( f , seq )); + BOOST_TEST(const_(f)(element1) == fusion::unpack_args(const_(f), seq )); + BOOST_TEST( f (element1) == fusion::unpack_args( f , const_(seq))); + BOOST_TEST(const_(f)(element1) == fusion::unpack_args(const_(f), const_(seq))); + } + + { + nc_foo nc_f; + + BOOST_TEST( nc_f (element1) == fusion::unpack_args( nc_f , seq )); + BOOST_TEST(const_(nc_f)(element1) == fusion::unpack_args(const_(nc_f), seq )); + BOOST_TEST( nc_f (element1) == fusion::unpack_args( nc_f , const_(seq))); + BOOST_TEST(const_(nc_f)(element1) == fusion::unpack_args(const_(nc_f), const_(seq))); + } + + BOOST_TEST(square(element1) == fusion::unpack_args(square, seq)); + + BOOST_TEST(func_ptr1(element1) == fusion::unpack_args(func_ptr1, seq)); + BOOST_TEST(func_ptr2(element1) == fusion::unpack_args(func_ptr2, seq)); + BOOST_TEST(func_ptr3(element1) == fusion::unpack_args(func_ptr3, seq)); + BOOST_TEST(func_ptr4(element1) == fusion::unpack_args(func_ptr4, seq)); +} + +template +void test_sequence_n(Sequence & seq, boost::mpl::int_<2>) +{ + { + foo f; + + BOOST_TEST( f (element1, element2) == fusion::unpack_args( f , seq)); + BOOST_TEST(const_(f)(element1, element2) == fusion::unpack_args(const_(f), seq)); + + BOOST_TEST( f (const_(element1), element2) == fusion::unpack_args( f , const_(seq))); + BOOST_TEST(const_(f)(const_(element1), element2) == fusion::unpack_args(const_(f), const_(seq))); + } + + BOOST_TEST(baz1(element1, element2) == fusion::unpack_args(baz1, seq)); + BOOST_TEST(baz2(element1, element2) == fusion::unpack_args(baz2, seq)); +} + +template +void test_sequence_n(Sequence & seq, boost::mpl::int_<3>) +{ + foo f; + + BOOST_TEST( f (element1, element2, element3) == fusion::unpack_args( f , seq)); + BOOST_TEST(const_(f)(element1, element2, element3) == fusion::unpack_args(const_(f), seq)); +} + +//////////////////////////////////////////////////////////////////////////////// +template +void test_sequence(Sequence & seq) +{ + test_sequence_n(seq, fusion::size(seq)); +} + +//////////////////////////////////////////////////////////////////////////////// +int main() +{ + typedef fusion::vector<> vector0; + typedef fusion::vector vector1; + typedef fusion::vector vector2; + typedef fusion::vector vector3; + + vector0 v0; + vector1 v1(element1); + vector2 v2(element1, element2); + vector3 v3(element1, element2, element3); + + test_sequence(v0); + test_sequence(v1); + test_sequence(v2); + test_sequence(v3); + + typedef fusion::list<> list0; + typedef fusion::list list1; + typedef fusion::list list2; + typedef fusion::list list3; + + list0 l0; + list1 l1(element1); + list2 l2(element1, element2); + list3 l3(element1, element2, element3); + + test_sequence(l0); + test_sequence(l1); + test_sequence(l2); + test_sequence(l3); +} diff --git a/test/sequence/value_at.hpp b/test/sequence/value_at.hpp new file mode 100644 index 00000000..72eebad9 --- /dev/null +++ b/test/sequence/value_at.hpp @@ -0,0 +1,87 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include + +#if !defined(FUSION_AT) +#define FUSION_AT at_c +#endif + +#if !defined(FUSION_VALUE_AT) +#define FUSION_VALUE_AT(S, N) result_of::value_at_c +#endif + +namespace +{ + // something to prevent warnings for unused variables + template void dummy(const T&) {} + + class A {}; +} + +void +test() +{ + using namespace boost::fusion; + + double d = 2.7; + A a; + FUSION_SEQUENCE t(1, d, a, 2); + const FUSION_SEQUENCE ct(t); + + int i = FUSION_AT<0>(t); + int i2 = FUSION_AT<3>(t); + + BOOST_TEST(i == 1 && i2 == 2); + + int j = FUSION_AT<0>(ct); + BOOST_TEST(j == 1); + + FUSION_AT<0>(t) = 5; + BOOST_TEST(FUSION_AT<0>(t) == 5); + +#if defined(FUSION_TEST_FAIL) + FUSION_AT<0>(ct) = 5; // can't assign to const +#endif + + double e = FUSION_AT<1>(t); + BOOST_TEST(e > 2.69 && e < 2.71); + + FUSION_AT<1>(t) = 3.14+i; + BOOST_TEST(FUSION_AT<1>(t) > 4.13 && FUSION_AT<1>(t) < 4.15); + +#if defined(FUSION_TEST_FAIL) + FUSION_AT<4>(t) = A(); // can't assign to const + dummy(FUSION_AT<5>(ct)); // illegal index +#endif + + ++FUSION_AT<0>(t); + BOOST_TEST(FUSION_AT<0>(t) == 6); + + typedef FUSION_SEQUENCE seq_type; + + BOOST_STATIC_ASSERT(!( + boost::is_const::value)); + + // constness should not affect + BOOST_STATIC_ASSERT(!( + boost::is_const::value)); + + BOOST_STATIC_ASSERT(!( + boost::is_const::value)); + + // constness should not affect + BOOST_STATIC_ASSERT(!( + boost::is_const::value)); + + dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables +} diff --git a/test/sequence/vector_comparison.cpp b/test/sequence/vector_comparison.cpp new file mode 100644 index 00000000..ef8e750e --- /dev/null +++ b/test/sequence/vector_comparison.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE vector +#include "comparison.hpp" + +int +main() +{ + equality_test(); + ordering_test(); + return boost::report_errors(); +} diff --git a/test/sequence/vector_construction.cpp b/test/sequence/vector_construction.cpp new file mode 100644 index 00000000..cabec110 --- /dev/null +++ b/test/sequence/vector_construction.cpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE vector +#include "construction.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} diff --git a/test/sequence/vector_copy.cpp b/test/sequence/vector_copy.cpp new file mode 100644 index 00000000..997ad089 --- /dev/null +++ b/test/sequence/vector_copy.cpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include + +#define FUSION_SEQUENCE vector +#include "copy.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/vector_iterator.cpp b/test/sequence/vector_iterator.cpp new file mode 100644 index 00000000..a04f642e --- /dev/null +++ b/test/sequence/vector_iterator.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE vector +#define FUSION_TRAVERSAL_TAG random_access_traversal_tag +#include "./iterator.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + + + diff --git a/test/sequence/vector_make.cpp b/test/sequence/vector_make.cpp new file mode 100644 index 00000000..ff80e84c --- /dev/null +++ b/test/sequence/vector_make.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include + +#define FUSION_SEQUENCE vector +#include "make.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/vector_misc.cpp b/test/sequence/vector_misc.cpp new file mode 100644 index 00000000..69f488e4 --- /dev/null +++ b/test/sequence/vector_misc.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE vector +#include "misc.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/vector_mutate.cpp b/test/sequence/vector_mutate.cpp new file mode 100644 index 00000000..151c32c5 --- /dev/null +++ b/test/sequence/vector_mutate.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE vector +#include "mutate.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/vector_n.cpp b/test/sequence/vector_n.cpp new file mode 100644 index 00000000..49550b80 --- /dev/null +++ b/test/sequence/vector_n.cpp @@ -0,0 +1,231 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + + +int +main() +{ + using namespace boost::fusion; + using namespace boost; + using namespace std; + + { + vector0 vec; + (void) vec; + cout << "(): " << sizeof(vec) << endl; + } + + { + typedef vector1 type; + type vec; + BOOST_STATIC_ASSERT(result_of::size::value == 1); + + BOOST_TEST(at_c<0>(vec) == 0); + BOOST_STATIC_ASSERT((is_same::type>::value)); + + // prove that it is mutable + at_c<0>(vec) = 987; + BOOST_TEST(at_c<0>(vec) == 987); + } + + { + typedef vector1 type; + type vec(123); + BOOST_TEST(at_c<0>(vec) == 123); + cout << "(int): " << sizeof(vec) << endl; + } + + { // testing const vector + vector1 const vec(999); + BOOST_TEST(at_c<0>(vec) == 999); + +#ifdef FUSION_TEST_COMPILE_FAIL + at_c<0>(vec) = 321; +#endif + } + + { + vector1 t1(123L); // try conversion from long to int + vector1 t2(t1); // try copy + (void)t2; + } + + { + typedef vector2 type; + type vec; + BOOST_STATIC_ASSERT(result_of::size::value == 2); + + BOOST_TEST(at_c<0>(vec) == 0); + BOOST_TEST(at_c<1>(vec) == char()); + + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + } + + { + typedef vector2 type; + type vec(123, 'x'); + BOOST_TEST(at_c<0>(vec) == 123); + BOOST_TEST(at_c<1>(vec) == 'x'); + cout << "(int, char): " << sizeof(vec) << endl; + } + + { + vector2 t1(123, 456); + vector2 t2(t1); + (void)t2; + } + + { + typedef vector3 type; + type vec; + BOOST_STATIC_ASSERT(result_of::size::value == 3); + + BOOST_TEST(at_c<0>(vec) == 0); + BOOST_TEST(at_c<1>(vec) == char()); + BOOST_TEST(at_c<2>(vec) == double()); + + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + } + + { + typedef vector3 type; + type vec(123, 'x', 123.456); + BOOST_TEST(at_c<0>(vec) == 123); + BOOST_TEST(at_c<1>(vec) == 'x'); + BOOST_TEST(at_c<2>(vec) >= 123.455 && at_c<2>(vec) <= 123.457); + cout << "(int, char, double): " << sizeof(vec) << endl; + } + + { + typedef vector4 type; + type vec(123, 'x', 123.456, true); + cout << "(int, char, double, bool): " << sizeof(vec) << endl; + } + + { + typedef vector4 type; + type vec(123, 'x', true, 123.456); + cout << "(int, char, bool, double): " << sizeof(vec) << endl; + } + + { + typedef vector7 type; + type vec(false, 'x', 3, 4, 5, 6.0, 7.0); + + BOOST_TEST(at_c<0>(vec) == false); + BOOST_TEST(at_c<1>(vec) == 'x'); + BOOST_TEST(at_c<2>(vec) == 3); + BOOST_TEST(at_c<3>(vec) == 4); + BOOST_TEST(at_c<4>(vec) == 5); + BOOST_TEST(at_c<5>(vec) >= 5.9 && at_c<5>(vec) <= 6.1); + BOOST_TEST(at_c<6>(vec) >= 6.9 && at_c<6>(vec) <= 7.1); + + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + BOOST_STATIC_ASSERT((is_same::type>::value)); + cout << "(bool, char, short, int, long, float, double): " << sizeof(vec) << endl; + } + + { + typedef vector10 type; + type vec; // compile check only + cout << "vector10 of int: " << sizeof(vec) << endl; + } + + { + typedef vector20< + int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int> type; + + type vec; // compile check only + cout << "vector20 of int: " << sizeof(vec) << endl; + } + + { + typedef vector30< + int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int> type; + + type vec; // compile check only + cout << "vector30 of int: " << sizeof(vec) << endl; + } + + { + typedef vector40< + int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int> type; + + type vec; // compile check only + cout << "vector40 of int: " << sizeof(vec) << endl; + } + + { + typedef vector50< + int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int + , int, int, int, int, int, int, int, int, int, int> type; + + type vec; // compile check only + cout << "vector50 of int: " << sizeof(vec) << endl; + } + + { + // testing copy and assign from a view + vector0 empty; + fusion::vector2 v(fusion::push_back(fusion::push_back(empty, 123), 456)); + BOOST_TEST(at_c<0>(v) == 123); + BOOST_TEST(at_c<1>(v) == 456); + v = fusion::push_back(fusion::push_back(empty, 123), 456); // test assign + BOOST_TEST(at_c<0>(v) == 123); + BOOST_TEST(at_c<1>(v) == 456); + } + + { + // testing copy and assign from a vector_c + mpl::vector_c vec_c; + fusion::vector2 v(vec_c); + BOOST_TEST(at_c<0>(v) == 123); + BOOST_TEST(at_c<1>(v) == 456); + v = mpl::vector_c(); // test assign + BOOST_TEST(at_c<0>(v) == 123); + BOOST_TEST(at_c<1>(v) == 456); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/vector_tie.cpp b/test/sequence/vector_tie.cpp new file mode 100644 index 00000000..272421dc --- /dev/null +++ b/test/sequence/vector_tie.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include + +#define FUSION_SEQUENCE vector +#include "tie.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/vector_value_at.cpp b/test/sequence/vector_value_at.cpp new file mode 100644 index 00000000..97859bcd --- /dev/null +++ b/test/sequence/vector_value_at.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 1999-2003 Jaakko Järvi + Copyright (c) 2001-2006 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#define FUSION_SEQUENCE vector +#include "value_at.hpp" + +int +main() +{ + test(); + return boost::report_errors(); +} + diff --git a/test/sequence/zip_view.cpp b/test/sequence/zip_view.cpp new file mode 100644 index 00000000..e4b3fa9a --- /dev/null +++ b/test/sequence/zip_view.cpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +int main() +{ + using namespace boost::fusion; + { + typedef vector2 int_vector; + typedef vector2 char_vector; + typedef vector seqs_type; + typedef zip_view view; + + BOOST_MPL_ASSERT((boost::mpl::equal_to::type, boost::fusion::result_of::size::type>)); + BOOST_STATIC_ASSERT((boost::fusion::result_of::size::value == 2)); + + int_vector iv(1,2); + char_vector cv('a', 'b'); + seqs_type seqs(iv, cv); + view v(seqs); + + BOOST_TEST(at_c<0>(v) == make_vector(1, 'a')); + BOOST_TEST(at_c<1>(v) == make_vector(2, 'b')); + BOOST_TEST(front(v) == make_vector(1, 'a')); + BOOST_TEST(back(v) == make_vector(2, 'b')); + BOOST_TEST(*next(begin(v)) == make_vector(2, 'b')); + BOOST_TEST(*prior(end(v)) == make_vector(2, 'b')); + BOOST_TEST(advance_c<2>(begin(v)) == end(v)); + BOOST_TEST(advance_c<-2>(end(v)) == begin(v)); + BOOST_TEST(distance(begin(v), end(v)) == 2); + + BOOST_STATIC_ASSERT((boost::fusion::result_of::distance::type, boost::fusion::result_of::end::type>::value == 2)); + + BOOST_MPL_ASSERT((boost::is_same::type, vector >)); + BOOST_MPL_ASSERT((boost::is_same::type>::type, vector >)); + } + { + using namespace boost; + typedef mpl::vector2 v1_type; + typedef mpl::vector2 v2_type; + typedef fusion::vector seqs_type; + typedef fusion::zip_view view; + + v1_type v1; + v2_type v2; + seqs_type seqs(v1,v2); + view v(seqs); + BOOST_TEST((fusion::at_c<0>(v) == mpl::vector2())); + BOOST_TEST((fusion::at_c<1>(v) == mpl::vector2())); + BOOST_TEST((fusion::front(v) == mpl::vector2())); + BOOST_TEST((fusion::back(v) == mpl::vector2())); + BOOST_TEST((*fusion::next(fusion::begin(v)) == mpl::vector2())); + BOOST_TEST((*fusion::prior(fusion::end(v)) == mpl::vector2())); + BOOST_TEST(fusion::advance_c<2>(fusion::begin(v)) == fusion::end(v)); + BOOST_TEST(fusion::advance_c<-2>(fusion::end(v)) == fusion::begin(v)); + BOOST_TEST(fusion::distance(fusion::begin(v), fusion::end(v)) == 2); + } + return boost::report_errors(); +} + diff --git a/test/sequence/zip_view2.cpp b/test/sequence/zip_view2.cpp new file mode 100644 index 00000000..b4054c38 --- /dev/null +++ b/test/sequence/zip_view2.cpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +int main() +{ + { + using namespace boost::fusion; + typedef vector2 int_vector; + typedef vector2 char_vector; + typedef list char_list; + typedef vector seqs_type; + typedef zip_view view; + + BOOST_MPL_ASSERT((boost::mpl::equal_to::type, boost::fusion::result_of::size::type>)); + BOOST_STATIC_ASSERT((boost::fusion::result_of::size::value == 2)); + + int_vector iv(1,2); + char_vector cv('a', 'b'); + char_list cl('y','z'); + seqs_type seqs(iv, cv, cl); + view v(seqs); + + BOOST_TEST(at_c<0>(v) == make_vector(1, 'a', 'y')); + BOOST_TEST(at_c<1>(v) == make_vector(2, 'b', 'z')); + BOOST_TEST(front(v) == make_vector(1, 'a', 'y')); + BOOST_TEST(*next(begin(v)) == make_vector(2, 'b', 'z')); + BOOST_TEST(advance_c<2>(begin(v)) == end(v)); + BOOST_TEST(distance(begin(v), end(v)) == 2); + BOOST_STATIC_ASSERT((boost::fusion::result_of::distance::type, boost::fusion::result_of::end::type>::value == 2)); + + BOOST_MPL_ASSERT((boost::is_same::type, vector >)); + BOOST_MPL_ASSERT((boost::is_same::type>::type, vector >)); + } + return boost::report_errors(); +} diff --git a/todo.txt b/todo.txt new file mode 100644 index 00000000..66899882 --- /dev/null +++ b/todo.txt @@ -0,0 +1,8 @@ +* Consider object equivalent of functions and algorithms (so you can do transform(iterators, deref()) with needing to put together a wrapper for deref). +* Consider segmented sequence / algorithm support +* Consider utility element_ref::type thats consts and refs as appropriate +* Improved motivation section +* Expand details of view concept +* Examples, examples, examples +* unpack_args documentation +* look at lambda stuff \ No newline at end of file