Special thanks to David Abrahams, Douglas Gregor, Hartmut Kaiser, Aleksey Gurtovoy,
Peder Holt, Daniel Wallin, Jaakko Jarvi, Jeremiah Willcock, Dan Marsden, Eric
diff --git a/doc/html/fusion/adapted.html b/doc/html/fusion/adapted.html
index 0a9121e6..92928c4b 100644
--- a/doc/html/fusion/adapted.html
+++ b/doc/html/fusion/adapted.html
@@ -3,7 +3,7 @@
- Fusion provides a couple of adapters for other sequences such as std::pair,
+ 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
+ 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
- [13]
+ [13]
.
[13]
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
diff --git a/doc/html/fusion/adapted/boost__array.html b/doc/html/fusion/adapted/boost__array.html
index b36302b5..168be02e 100644
--- a/doc/html/fusion/adapted/boost__array.html
+++ b/doc/html/fusion/adapted/boost__array.html
@@ -3,7 +3,7 @@
Unlike MPL, Fusion
algorithms are lazy and non sequence-type preserving. What does that mean?
@@ -57,41 +58,41 @@
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
+ 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
+ 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 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
+ 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,
+ 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.
@@ -33,10 +34,10 @@
The iteration algorithms provide the fundamental algorithms for traversing
a sequence repeatedly applying an operation to its elements.
-
- For a sequence Seq, initial
- state, and binary function object or function pointer f,
- accumulate repeatedly applies binary f
- to each element of Seq
+ For a sequence Seq, initial
+ state, and binary function object or function pointer f,
+ accumulate repeatedly applies binary f
+ to each element of Seq
and the previous state.
- 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
+ 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
@@ -100,7 +100,7 @@
- initial_state
+ initial_state
@@ -117,14 +117,14 @@
- f
+ f
- boost::result_of<F(E,S)>::type is the return type of f(e,s)
- for each element e
- of type E in seq, and current state s of type S
+ boost::result_of<F(E,S)>::type is the return type of f(e,s)
+ for each element e
+ of type E in seq, and current state s of type S
- Semantics: Equivalent to f(eN....f(e2,f(e1,initial_state)))
- where e1...eN are the elements of seq.
+ Semantics: Equivalent to f(eN....f(e2,f(e1,initial_state)))
+ where e1...eN are the elements of seq.
- For a sequence Seq, initial
- state, and binary function object or function pointer f,
- fold repeatedly applies binary f
- to each element of Seq
+ For a sequence Seq, initial
+ state, and binary function object or function pointer f,
+ fold repeatedly applies binary f
+ to each element of Seq
and the previous state.
- A model of Forward
- Sequence,f(e,s) must be a valid expression for
- each element e
- in seq, and current
- state s
+ A model of Forward
+ Sequence,f(e,s) must be a valid expression for
+ each element e
+ in seq, and current
+ state s
@@ -100,7 +100,7 @@
- initial_state
+ initial_state
@@ -117,14 +117,14 @@
- f
+ f
- boost::result_of<F(E,S)>::type is the return type of f(e,s)
- for each element e
- of type E in seq, and current state s of type S
+ boost::result_of<F(E,S)>::type is the return type of f(e,s)
+ for each element e
+ of type E in seq, and current state s of type S
- Semantics: Equivalent to f(eN....f(e2,f(e1,initial_state)))
- where e1...eN are the elements of seq.
+ Semantics: Equivalent to f(eN....f(e2,f(e1,initial_state)))
+ where e1...eN are the elements of seq.
- A model of Forward
- Sequence, f(e) must be a valid expression for
- each element e
- in seq
+ A model of Forward
+ Sequence, f(e) must be a valid expression for
+ each element e
+ in seq
- The initial state for the first application of F
+ The initial state for the first application of F
- F
+ F
- boost::result_of<F(E,S)>::type is the return type of f(e,s)
- for each element e
- of type E in seq, and current state s of type S
+ boost::result_of<F(E,S)>::type is the return type of f(e,s)
+ for each element e
+ of type E in seq, and current state s of type S
- Semantics: Returns the result of applying
- accumulate to a sequence
- of type Sequence, with
- an initial state of type State
- and binary function object or function pointer of type F.
+ Semantics: Returns the result of applying
+ accumulate to a sequence
+ of type Sequence, with
+ an initial state of type State
+ and binary function object or function pointer of type F.
- The initial state for the first application of F
+ The initial state for the first application of F
- F
+ F
- boost::result_of<F(E,S)>::type is the return type of f(e,s)
- for each element e
- of type E in seq, and current state s of type S
+ boost::result_of<F(E,S)>::type is the return type of f(e,s)
+ for each element e
+ of type E in seq, and current state s of type S
- Semantics: Returns the result of applying
- fold to a sequence of
- type Sequence, with an
- initial state of type State
- and binary function object or function pointer of type F.
+ Semantics: Returns the result of applying
+ fold to a sequence of
+ type Sequence, with an
+ initial state of type State
+ and binary function object or function pointer of type F.
- A metafunction returning the result type of applying for_each to a sequence. The
- return type of for_each is always void.
+ A metafunction returning the result type of applying for_each to a sequence. The
+ return type of for_each is always 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.
+ 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.
- For a sequence seq and
- unary function object f,
- all returns true if
- f returns true for every
- element of seq.
+ For a sequence seq and
+ unary function object f,
+ all returns true if
+ f returns true for every
+ element of seq.
- A model of Forward
- Sequence, f(e) is a valid expression, convertible
- to bool, for every
- element e in seq
+ A model of Forward
+ Sequence, f(e) is a valid expression, convertible
+ to bool, for every
+ element e in seq
- Semantics: Returns true if and only
- if f(e)
- evaluates to true for every
- element e in seq.
+ Semantics: Returns true if and only
+ if f(e)
+ evaluates to true for every
+ element e in seq.
- For a sequence seq and
- unary function object f,
- any returns true if
- f returns true for at
- least one element of seq.
+ For a sequence seq and
+ unary function object f,
+ any returns true if
+ f returns true for at
+ least one element of seq.
- A model of Forward
- Sequence, f(e) must be a valid expression, convertible
- to bool, for each
- element e in seq
+ A model of Forward
+ Sequence, f(e) must be a valid expression, convertible
+ to bool, for each
+ element e in seq
- Semantics: Returns true if and only
- if f(e)
- evaluates to true for some
- element e in seq.
+ Semantics: Returns true if and only
+ if f(e)
+ evaluates to true for some
+ element e in seq.
- A model of Forward
- Sequence, e==t
- must be a valid expression, convertible to bool,
- for each element e
- in seq
+ A model of Forward
+ Sequence, e==t
+ must be a valid expression, convertible to bool,
+ for each element e
+ in seq
- Semantics: Returns the number of elements
- of type T and equal to
- t in seq.
+ Semantics: Returns the number of elements
+ of type T and equal to
+ t in seq.
Returns the number of elements within a sequence with a type for which
- a given unary function object evaluates to true.
+ a given unary function object evaluates to true.
- A model of Forward
- Sequence, f(e) is a valid expression, convertible
- to bool, for each
- element e in seq
+ A model of Forward
+ Sequence, f(e) is a valid expression, convertible
+ to bool, for each
+ element e in seq
- Semantics: Returns the number of elements
- in seq where f evaluates to true.
+ Semantics: Returns the number of elements
+ in seq where f evaluates to true.
- Return type: A model of the same iterator
- category as the iterators of 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)
+ 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)
Finds the first element within a sequence with a type for which a given
MPL
- Lambda Expression evaluates to boost::mpl::true_.
+ Lambda Expression evaluates to boost::mpl::true_.
- Return type: An iterator of the same
- iterator category as the iterators of 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 ExpressionF
- evaluates to boost::mpl::true_, or end(seq)
+ Semantics: Returns the first element
+ of seq for which MPL
+ Lambda ExpressionF
+ evaluates to boost::mpl::true_, or end(seq)
if there is no such element.
- For a sequence seq and
- unary function object f,
- none returns true if
- f returns false for every
- element of seq.
+ For a sequence seq and
+ unary function object f,
+ none returns true if
+ f returns false for every
+ element of seq.
- A model of Forward
- Sequence, f(e) is a valid expression, convertible
- to bool, for every
- element e in seq
+ A model of Forward
+ Sequence, f(e) is a valid expression, convertible
+ to bool, for every
+ element e in seq
- Semantics: Returns true if and only
- if f(e)
- evaluates to false for every
- element e in seq. Result equivalent to !any(seq,f).
+ Semantics: Returns true if and only
+ if f(e)
+ evaluates to false for every
+ element e in seq. Result equivalent to !any(seq,f).
- 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.
+ 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.
- 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.
+ 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.
- Semantics: Returns the return type of
- count. The return type is always
- int.
+ Semantics: Returns the return type of
+ count. The return type is always
+ int.
- A metafunction that returns the result type of count_if
+ A metafunction that returns the result type of count_if
given the sequence and predicate types.
- Semantics: Returns the return type of
- count_if. The return type is
- always int.
+ Semantics: Returns the return type of
+ count_if. The return type is
+ always int.
- Return type: A model of the same iterator
- category as the iterators of Sequence.
+ 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
+ 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.
- Return type: A model of the same iterator
- category as the iterators of Sequence.
+ 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.
+ 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.
- 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.
+ 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.
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.
- Semantics: Returns a new sequence, containing
- all the elements of seq
- except the element at pos.
+ Semantics: Returns a new sequence, containing
+ all the elements of seq
+ except the element at pos.
- Semantics: Returns a new sequence, with
- all the elements of seq,
- in their original order, except those in the range [first,last).
+ Semantics: Returns a new sequence, with
+ all the elements of seq,
+ in their original order, except those in the range [first,last).
- Semantics: Returns a new sequence, containing
- all the elements of seq,
- except those with key Key.
+ Semantics: Returns a new sequence, containing
+ all the elements of seq,
+ except those with key Key.
- Semantics: Returns a sequence containing
- all the elements of seq
- of type T. Equivalent
- to filter_if<boost::same_type<_,T>>(seq).
+ Semantics: Returns a sequence containing
+ all the elements of seq
+ of type T. Equivalent
+ to filter_if<boost::same_type<_,T>>(seq).
- For a given sequence, filter_if returns a new sequences
+ 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_.
+ Lambda Expression evaluates to boost::mpl::true_.
- 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
+ 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.
- Semantics: Returns a new sequence, containing
- all the elements of seq,
+ 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.
+ t inserted at iterator
+ pos.
- Semantics: Returns a new sequence, containing
- all the elements of seq,
- and the elements of range
- inserted at iterator pos.
+ 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.
- Semantics: Returns a sequence containing
- all the elements of lhs
- followed by all the elements of rhs.
+ Semantics: Returns a sequence containing
+ all the elements of lhs
+ followed by all the elements of rhs.
The order of th elements is preserved.
- Semantics: Returns a new sequence containing
- all the elements of seq,
+ 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.
+ same order as they were in seq.
- Semantics: Returns a new sequence containing
- all the elements of seq,
+ 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.
+ same order as they were in seq.
- 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.
+ 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.
- Semantics: Returns a new sequence, containing
- all the elements of seq,
- and new element t appended
+ 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.
+ seq.
- 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).
+ 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).
Returns a new sequence, containing all the elements of the original except
- those where a given unary function object evaluates to true.
+ those where a given unary function object evaluates to true.
- Semantics: Returns a new sequence, containing
- all the elements of seq,
+ 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).
+ Pred evaluates to boost::mpl::true_. Equivalent to filter<boost::mpl::not_<Pred>
+ >(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
+ 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
- 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.
+ 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.
- A function object for which f(e) is a valid expression, convertible
- to bool, for each
- element e in seq
+ A function object for which f(e) is a valid expression, convertible
+ to bool, for each
+ element e in seq
- Semantics: Returns a new sequence with
- all the elements of seq,
- with new_value assigned
- to each element for which f
- evaluates to true.
+ Semantics: Returns a new sequence with
+ all the elements of seq,
+ with new_value assigned
+ to each element for which f
+ evaluates to true.
- Semantics: Returns a new sequence containing
- all the elements of seq
+ Semantics: Returns a new sequence containing
+ all the elements of seq
in reverse order.
- For a sequence seq and
- function object or function pointer f,
- transform returns a new
- sequence with elements created by applying f(e) to each element of e
- of seq.
+ For a sequence seq and
+ function object or function pointer f,
+ transform returns a new
+ sequence with elements created by applying f(e) to each element of e
+ of seq.
- f(e)
- is a valid expression for each element e
- of seq. boost::result_of<F(E)>::type is the return type of f when called with a value of
- each element type E.
+ f(e)
+ is a valid expression for each element e
+ of seq. boost::result_of<F(E)>::type is the return type of f when called with a value of
+ each element type E.
- Semantics: Returns a new sequence, containing
- the return values of f(e) for each element e
- within seq.
+ Semantics: Returns a new sequence, containing
+ the return values of f(e) for each element e
+ within seq.
- f(e1,e2)
- is a valid expression for each pair of elements e1
- of seq1 and e2 of seq2.
- boost::result_of<F(E1,E2)>::type is the return type of f when called with elements of
- type E1 and E2
+ f(e1,e2)
+ is a valid expression for each pair of elements e1
+ of seq1 and e2 of seq2.
+ boost::result_of<F(E1,E2)>::type is the return type of f when called with elements of
+ type E1 and E2
- 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.
+ 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.
- 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'))
+ 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'))
- Returns the result type of erase, given the input sequence
+ Returns the result type of erase, given the input sequence
and range delimiting iterator types.
- Semantics: Returns a new sequence with
- the elements between It1
- and It2 removed.
+ Semantics: Returns a new sequence with
+ the elements between It1
+ and It2 removed.
- Semantics: Returns a sequence with the
- elements of Sequence,
- except those with key Key.
+ Semantics: Returns a sequence with the
+ elements of Sequence,
+ except those with key Key.
- 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.
+ 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.
- Returns the result type of filter_if given the sequence
+ Returns the result type of filter_if given the sequence
and unary MPL
Lambda Expression predicate type.
- Semantics: Returns a sequence containing
- the elements of Sequence
- for which Pred evaluates
- to boost::mpl::true_.
+ Semantics: Returns a sequence containing
+ the elements of Sequence
+ for which Pred evaluates
+ to boost::mpl::true_.
- Returns the result type of insert, given the sequence,
+ Returns the result type of insert, given the sequence,
position iterator and insertion types.
- Semantics: Returns a sequence with an
- element of type T inserted
- at position Position
- in Sequence.
+ Semantics: Returns a sequence with an
+ element of type T inserted
+ at position Position
+ in Sequence.
- Returns the result type of insert_range, given the input
+ Returns the result type of insert_range, given the input
sequence, position iterator and insertion range types.
- Semantics: Returns a sequence with the
- elements of Range inserted
- at position Position
- into Sequence.
+ Semantics: Returns a sequence with the
+ elements of Range inserted
+ at position Position
+ into Sequence.
- Semantics: Returns a sequence containing
- the elements of LhSequence
- followed by the elements of RhSequence.
+ 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.
- Semantics: Returns a sequence with all
- the elements of Sequence
+ Semantics: Returns a sequence with all
+ the elements of Sequence
except the last element.
- Semantics: Returns a sequence with all
- the elements of Sequence
+ Semantics: Returns a sequence with all
+ the elements of Sequence
except the first element.
- Returns the result type of push_back, given the types of
+ Returns the result type of push_back, given the types of
the input sequence and element to push.
- Semantics: Returns a sequence with the
- elements of Sequence
- and an element of type T
+ Semantics: Returns a sequence with the
+ elements of Sequence
+ and an element of type T
added to the end.
- Returns the result type of push_front, given the types
+ Returns the result type of push_front, given the types
of the input sequence and element to push.
- Semantics: Returns a sequence with the
- elements of Sequence
- and an element of type T
+ Semantics: Returns a sequence with the
+ elements of Sequence
+ and an element of type T
added to the beginning.
- 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.
+ 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.
- Returns the result type of remove_if, given the input sequence
+ Returns the result type of remove_if, given the input sequence
and unary MPL
Lambda Expression predicate types.
- Semantics: Returns a sequence containing
- the elements of Sequence
- for which Pred evaluates
- to boost::mpl::false_.
+ Semantics: Returns a sequence containing
+ the elements of Sequence
+ for which Pred evaluates
+ to boost::mpl::false_.
- Returns the result type of replace, given the types of
+ Returns the result type of replace, given the types of
the input sequence and element to replace.
- Semantics: Returns a sequence with the
- elements in the reverse order to Sequence.
+ Semantics: Returns a sequence with the
+ elements in the reverse order to Sequence.
- For a sequence seq and
- function object or function pointer f,
- transform returns a new
- sequence with elements created by applying f(e) to each element of e
- of seq.
+ For a sequence seq and
+ function object or function pointer f,
+ transform returns a new
+ sequence with elements created by applying f(e) to each element of e
+ of seq.
- f(e)
- is a valid expression for each element e
- of seq. boost::result_of<F(E)>::type is the return type of f when called with a value of
- each element type E.
+ f(e)
+ is a valid expression for each element e
+ of seq. boost::result_of<F(E)>::type is the return type of f when called with a value of
+ each element type E.
- Semantics: Returns a new sequence, containing
- the return values of f(e) for each element e
- within seq.
+ Semantics: Returns a new sequence, containing
+ the return values of f(e) for each element e
+ within seq.
- f(e1,e2)
- is a valid expression for each pair of elements e1
- of seq1 and e2 of seq2.
- boost::result_of<F(E1,E2)>::type is the return type of f when called with elements of
- type E1 and E2
+ f(e1,e2)
+ is a valid expression for each pair of elements e1
+ of seq1 and e2 of seq2.
+ boost::result_of<F(E1,E2)>::type is the return type of f when called with elements of
+ type E1 and E2
- 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.
+ 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.
- Return type: A model of the most restrictive
- traversal category of sequences Sequence1
- to SequenceN.
+ Return type: A model of the most restrictive
+ traversal category of sequences Sequence1
+ to SequenceN.
- Semantics: Return a sequence containing
+ 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'))
+ (1,2,
+ 3)
+ and ('a','b',
+ 'c')
+ would return ((1,'a'),(2,'b'),(3,
+ 'c'))
- 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
+ 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).
- Semantics: Convert a fusion sequence,
- seq, to a map.
+ Semantics: Convert a fusion sequence,
+ seq, to a map.
- Precondition: The elements of the sequence
+ Precondition: The elements of the sequence
are assumed to be __fusionpair_s.
- There may be no duplicate fusion::pair key types.
+ There may be no duplicate fusion::pair key types.
- Return type: A list with same elements as the
- input sequence, Sequence.
+ Return type: A list with same elements as the
+ input sequence, Sequence.
- Semantics: Convert a fusion sequence,
- Sequence, to a list.
+ Semantics: Convert a fusion sequence,
+ Sequence, to a list.
- Return type: A map with same elements as the
- input sequence, Sequence.
+ Return type: A map with same elements as the
+ input sequence, Sequence.
- Semantics: Convert a fusion sequence,
- Sequence, to a map.
+ Semantics: Convert a fusion sequence,
+ Sequence, to a map.
- Precondition: The elements of the sequence
+ Precondition: The elements of the sequence
are assumed to be __fusionpair_s.
- There may be no duplicate fusion::pair key types.
+ There may be no duplicate fusion::pair key types.
- Return type: A vector with same elements as
- the input sequence, Sequence.
+ Return type: A vector with same elements as
+ the input sequence, Sequence.
- Semantics: Convert a fusion sequence,
- Sequence, to a vector.
+ Semantics: Convert a fusion sequence,
+ Sequence, to a vector.
- 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
+ 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:
- 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
+ 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:
- 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
+ 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:
- The variadic function accepts 0
- to FUSION_MAX_VECTOR_SIZE
- [8]
- 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
+ The variadic function accepts 0
+ to FUSION_MAX_VECTOR_SIZE
+ [8]
+ 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:
- 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
+ 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:
- The variadic function accepts 0
- to FUSION_MAX_MAP_SIZE
- elements, where FUSION_MAX_MAP_SIZE
- is a user definable predefined maximum that defaults to 10, and a corresponding number of key types.
- You may define the preprocessor constant FUSION_MAX_MAP_SIZE
+ The variadic function accepts 0
+ to FUSION_MAX_MAP_SIZE
+ elements, where FUSION_MAX_MAP_SIZE
+ is a user definable predefined maximum that defaults to 10, and a corresponding number of key types.
+ You may define the preprocessor constant FUSION_MAX_MAP_SIZE
before including any Fusion header to change the default. Example:
- Semantics: Create a map of references from x0,x1,...xN with keys K0,K1,...KN
+ Semantics: Create a map of references from x0,x1,...xN with keys K0,K1,...KN
- 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))
- [10]
+ 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))
+ [10]
.
- 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
+ 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:
- 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
+ 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:
- Return type: A cons with head element, Car, of type converted following the
+ Return type: A cons with head element, Car, of type converted following the
rules for element
- conversion, and tail, Cdr.
+ conversion, and tail, Cdr.
- Semantics: Create a cons from Car
- (head) and optional Cdr
+ Semantics: Create a cons from Car
+ (head) and optional Cdr
(tail).
- 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
+ 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:
- 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
+ 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:
- Semantics: A map with fusion::pair elements where the second_type is converted following
+ 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
+ Precondition: There may be no duplicate
key types.
- The variadic function accepts 0
- to FUSION_MAX_VECTOR_SIZE
- [11]
- 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
+ The variadic function accepts 0
+ to FUSION_MAX_VECTOR_SIZE
+ [11]
+ 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:
- Return type: A set with elements of types converted
+ Return type: A set with elements of types converted
following the rules for element
conversion.
- Semantics: Create a set from T0,T1,...TN.
+ Semantics: Create a set from T0,T1,...TN.
- Precondition: There may be no duplicate
+ Precondition: There may be no duplicate
key types.
- 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
+ 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:
- The variadic function accepts 0
- to FUSION_MAX_MAP_SIZE
- elements, where FUSION_MAX_MAP_SIZE
- is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant
- FUSION_MAX_MAP_SIZE before
+ The variadic function accepts 0
+ to FUSION_MAX_MAP_SIZE
+ elements, where FUSION_MAX_MAP_SIZE
+ is a user definable predefined maximum that defaults to 10. You may define the preprocessor constant
+ FUSION_MAX_MAP_SIZE before
including any Fusion header to change the default. Example:
- Semantics: Create a map of references from D0,D1,...DN with keys K0,K1,...KN
+ Semantics: Create a map of references from D0,D1,...DN with keys K0,K1,...KN
- 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
+ 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:
- list is a Forward
- Sequence of heterogenous typed data built on top of cons. It is more efficient than
- vector
+ 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).
- 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.
+ 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
+ You may define the preprocessor constant FUSION_MAX_LIST_SIZE
before including any Fusion header to change the default. Example:
- map is an Associative
+ map is an Associative
Sequence of heteregenous typed data elements. Each element is a key/data
- pair (see fusion::pair)
+ 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).
- 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.
+ 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:
- You may define the preprocessor constant FUSION_MAX_MAP_SIZE
+ You may define the preprocessor constant FUSION_MAX_MAP_SIZE
before including any Fusion header to change the default. Example:
- set is an Associative
+ 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).
- 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.
+ 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
+ You may define the preprocessor constant FUSION_MAX_SET_SIZE
before including any Fusion header to change the default. Example:
- vector is a Random
+ 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
+ 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.
- 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.
+ 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
+ You may define the preprocessor constant FUSION_MAX_VECTOR_SIZE
before including any Fusion header to change the default. Example:
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
+ easily be added. In fact, the library support for std::pair,
+ boost::array and MPL
sequences is entirely provided using the extension mechanism.
The Fusion extensibility mechanism uses tag
dispatching to call the correct code for a given sequence
@@ -96,9 +96,9 @@
}
- Next we need to enable the traits::tag_of
+ 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
+ our sequence. This is done by specializing traits::tag_of
for our sequence type.
@@ -114,8 +114,8 @@
}}}
- traits::tag_of also has a second template argument,
- that can be used in conjuction with boost::enable_if
+ traits::tag_of also has a second template argument,
+ that can be used in conjuction with boost::enable_if
to provide tag support for groups of related types. This feature is not necessary
for our sequence, but for an example see the code in:
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.
+ 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<typenameStruct,intPos>
@@ -163,37 +163,37 @@
index of the current element.
- The typedefs struct_type
- and index provide convenient
+ 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
+ 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
+ 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.
+ of traits::tag_of.
In isolation, the iterator implementation is pretty dry. Things should become
clearer as we add features to our implementation.
- 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
+ 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.
@@ -218,22 +218,22 @@
The implementation itself is pretty simple, it just uses 2 partial specializations
- to provide the type of the 2 different members of example_struct,
+ 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:
+ To understand how value_of_impl
+ is used by the library we will look at the implementation of value_of:
Ok, lets enable dereferencing of our iterator. In this case we must provide
- a suitable specialization of deref_impl.
+ a suitable specialization of deref_impl.
template<>
@@ -279,17 +279,17 @@
}
- 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:
+ 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:
- The actual implementation of deref_impl
- is slightly more complex than that of value_of_impl.
- We also need to implement the call
+ 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
+ sequence. We also require a little bit of metaprogramming to return const references if the underlying sequence
is const.
@@ -322,23 +322,23 @@
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
+ 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.
+ requiring implementation of a suitable xxxx_impl
+ for each feature xxxx.
- Ok, now we have seen the way value_of and deref work, everything else will
+ 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:
+ a next_impl:
template<>
@@ -360,40 +360,37 @@
};
- This should be very familiar from our deref_impl
+ 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
+ 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 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 Iteratordistance_impl
- and advance_impl also need
+ 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 Iteratordistance_impl
+ and advance_impl also need
to be provided in order to satisfy the necessary complexity guarantees. As
- our iterator is a Random
+ 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
+ Full implementations of prior_impl,
+ advance_impl, distance_impl and equal_to_impl
are provided in the example code.
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
+ we need to enable is_sequence
+ for our sequence type. As usual we just create an impl
type specialized for our sequence tag:
@@ -405,14 +402,14 @@
};
- We've some similar formalities to complete, providing category_of_impl
- so Fusion can correctly identify our sequence type, and is_view_impl
+ 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
+ get begin working so that we can get
an iterator to start accessing the data in our sequence.
@@ -435,33 +432,32 @@
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
+ 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.
+ For our Random
+ Access Sequence we will also need to implement size_impl,
+ value_at_impl and at_impl.
- In order for example_struct
+ 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
+ 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.
+ 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:
@@ -504,18 +500,18 @@
Its all very similar to the implementations we've seen previously, such as
- deref_impl and value_of_impl. Instead of identifying the
+ 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
+ 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.
+ of is_associative_impl.
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.
@@ -523,8 +519,8 @@
pattern.
- The support for std::pair, MPL
- sequences, and boost::array all use the same approach, and provide
+ 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.
The user of iterator_facade derives his iterator type from a specialization
of iterator_facade and passes the derived iterator type as the first template
@@ -57,8 +58,8 @@
type.
- A full worked example using iterator_facade is provided in triple.cpp
+ A full worked example using iterator_facade is provided in triple.cpp
in the extension examples.
- The above macro generates the necessary code to adapt struct_name
- as a model of Random
- Access Sequence and Associative
- Sequence. The sequence of (member_typeN,
+ The above macro generates the necessary code to adapt struct_name
+ as a model of Random
+ Access Sequence and Associative
+ Sequence. The sequence of (member_typeN,member_nameN,
- key_typeN)
+ key_typeN)
triples declare the type, name and key type of each of the struct members
that will be part of the sequence.
- The macro should be used at global scope, and struct_name
+ The macro should be used at global scope, and struct_name
should be the fully namespace qualified name of the struct to be converted.
- The above macro generates the necessary code to adapt struct_name
- as a model of Random
- Access Sequence. The sequence of (member_typeN,
- member_nameN)
+ The above macro generates the necessary code to adapt struct_name
+ as a model of Random
+ Access Sequence. The sequence of (member_typeN,
+ member_nameN)
pairs declare the type and names of each of the struct members that will
be part of the sequence.
- The macro should be used at global scope, and struct_name
+ The macro should be used at global scope, and struct_name
should be the fully namespace qualified name of the struct to be converted.
- The user of sequence_facade derives his sequence
- type from a specialization of sequence_facade and passes the derived
+ The user of sequence_facade derives his sequence
+ type from a specialization of sequence_facade and passes the derived
sequence type as the first template parameter. The second template parameter
should be the traversal category of the sequence being implemented. The 3rd
- parameter should be set to mpl::true_
+ parameter should be set to mpl::true_
if the sequence is a view.
- A full worked example using sequence_facade is provided in triple.cpp
+ A full worked example using sequence_facade is provided in triple.cpp
in the extension examples.
@@ -79,7 +80,7 @@
It is a name and a tuple written next to each other, left-to-right.
- Although the C++ syntax does not allow to replace (a,b,c)
+ Although the C++ syntax does not allow to replace (a,b,c)
with some Fusion Sequence, introducing
yet another function provides a solution:
@@ -87,25 +88,25 @@
invoke(f,my_sequence)
- Alternatively it is possible to apply a simple transformation to f
+ Alternatively it is possible to apply a simple transformation to f
in order to achieve the same effect:
ftuple<=> f' (tuple)
- Now, f' is an unary function that takes the arguments to
- f as a tuple; f'
- is the fused form of f.
+ Now, f' is an unary function that takes the arguments to
+ f as a tuple; f'
+ is the fused form of f.
Reading the above equivalence right-to-left to get the inverse transformation,
- f is the unfused
- form of f'.
+ f is the unfused
+ form of f'.
Having generic C++ code call back arbitrary functions provided by the client
used to be a heavily repetitive task, as different functions can differ in
@@ -118,8 +119,7 @@
Transforming a fused function into its unfused counterpart allows to create
function objects to accept arbitrary calls. In other words, an unary function
diff --git a/doc/html/fusion/functional/adapters.html b/doc/html/fusion/functional/adapters.html
index f5f0ecce..d0d579e1 100644
--- a/doc/html/fusion/functional/adapters.html
+++ b/doc/html/fusion/functional/adapters.html
@@ -1,13 +1,12 @@
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
for a target function object that is const or, if the target function object
is held by value, the adapter is const - these semantics have nothing to
do with the const qualification of a member function, which is referring
- to the type of object pointed to by this which is specified
+ to the type of object pointed to by this which is specified
with the first element in the sequence passed to the adapter).
If the target function is a pointer to a class members, the corresponding
object can be specified as a reference, pointer, or smart pointer. In case
- of the latter, a freestanding get_pointer function must
- be defined (Boost provides this function for std::auto_ptr
- and boost::shared_ptr).
+ of the latter, a freestanding get_pointer function must
+ be defined (Boost provides this function for std::auto_ptr
+ and boost::shared_ptr).
Creates a fused function as described above, initializes the target
- function with r.
+ function with r.
- fused<R>()
+ fused<R>()
- Creates a fused function as described above, attempts to use R's default constructor.
+ Creates a fused function as described above, attempts to use R's default constructor.
- f(s)
+ f(s)
- Calls r with the
- elements in s as
+ Calls r with the
+ elements in s as
its arguments.
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
for an target function object that is const or, if the target function
object is held by value, the adapter is const).
- Creates a fused function as described above, attempts to use R's default constructor.
+ Creates a fused function as described above, attempts to use R's default constructor.
- f(s)
+ f(s)
- Calls r with the
- elements in s as
+ Calls r with the
+ elements in s as
its arguments.
- The result is discared and the adapter's return type is void.
+ The result is discared and the adapter's return type is void.
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
for a target function object that is const or, if the target function object
is held by value, the adapter is const - these semantics have nothing to
do with the const qualification of a member function, which is referring
- to the type of object pointed to by this which is specified
+ to the type of object pointed to by this which is specified
with the first element in the sequence passed to the adapter).
If the target function is a pointer to a members function, the corresponding
object can be specified as a reference, pointer, or smart pointer. In case
- of the latter, a freestanding get_pointer function must
- be defined (Boost provides this function for std::auto_ptr
- and boost::shared_ptr).
+ of the latter, a freestanding get_pointer function must
+ be defined (Boost provides this function for std::auto_ptr
+ and boost::shared_ptr).
The target function must not be a pointer to a member object (dereferencing
@@ -65,19 +64,19 @@
Creates a fused function as described above, initializes the target
- function with r.
+ function with r.
- fused_procedure<R>()
+ fused_procedure<R>()
- Creates a fused function as described above, attempts to use R's default constructor.
+ Creates a fused function as described above, attempts to use R's default constructor.
- f(s)
+ f(s)
- Calls r with the
- elements in s as
+ Calls r with the
+ elements in s as
its arguments.
Detecting mutable LValues on a per-argument basis
is currently a compile time expensive operation (see The
Forwarding Problem for details). Therefore, there are two, lightweight
- and more restricted variants of this class template, unfused_lvalue_args and unfused_rvalue_args.
-
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
if the target function object is const - or, in case the target function
object is held by value, the adapter is const).
Creates a fused function as described above, initializes the target
- function with f.
+ function with f.
- UG()
+ UG()
- Creates a fused function as described above, attempts to use F's default constructor.
+ Creates a fused function as described above, attempts to use F's default constructor.
- ug(a0...aN)
+ ug(a0...aN)
- Calls f with a
+ Calls f with a
Sequence that contains references
- to the arguments a0...aN.
+ to the arguments a0...aN.
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
if the target function object is const - or, in case the target function
object is held by value, the adapter is const).
Creates a fused function as described above, initializes the target
- function with f.
+ function with f.
- UL()
+ UL()
- Creates a fused function as described above, attempts to use F's default constructor.
+ Creates a fused function as described above, attempts to use F's default constructor.
- ul(a0...aN)
+ ul(a0...aN)
- Calls f with a
+ Calls f with a
Sequence that contains references
- to the arguments a0...aN.
+ to the arguments a0...aN.
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
if the target function object is const - or, in case the target function
object is held by value, the adapter is const).
Creates a fused function as described above, initializes the target
- function with f.
+ function with f.
- UR()
+ UR()
- Creates a fused function as described above, attempts to use F's default constructor.
+ Creates a fused function as described above, attempts to use F's default constructor.
- ur(a0...aN)
+ ur(a0...aN)
- Calls f with a
+ Calls f with a
Sequence that contains references
- to the arguments a0...aN.
+ to the arguments a0...aN.
The type of the target function is allowed to be const qualified or a reference.
Const qualification is preserved and propagated appropriately (in other
- words, only const versions of operator() can be used
+ words, only const versions of operator() can be used
if the target function object is const - or, in case the target function
object is held by value, the adapter is const).
-
+
+
+
For Microsoft Visual C++ 7.1 (Visual Studio 2003)
the detection of the Function Object's const qualification easily causes
an internal error. Therefore the adapter is always treated as if it was
const.
-
-
+
+
+
+
+
If the type sequence passed to this template contains
non-reference elements, the element is copied only once - the call operator's
signature is optimized automatically to avoid by-value parameters.
-
Creates a fused function as described above, initializes the target
- function with f.
+ function with f.
- UT()
+ UT()
- Creates a fused function as described above, attempts to use F's default constructor.
+ Creates a fused function as described above, attempts to use F's default constructor.
- ut(a0...aN)
+ ut(a0...aN)
- Calls f with an
- instance of S (or
- a subsequence of S
+ Calls f with an
+ instance of S (or
+ a subsequence of S
starting at the first element, if fewer arguments are given and
- the overload hasn't been disabled) initialized with a0...aN.
+ the overload hasn't been disabled) initialized with a0...aN.
A pointer to a function, a pointer to member function, a pointer to member
data, or a class type whose objects can appear immediately to the left
of a function call operator.
+ note Once C++ supports the decltype keyword, all models
+ of Callable Object
+ will also be models of Deferred
Callable Object, because function objects won't need client-side
- support for result_of.
-
+ support for result_of.
+
+
Notation
-
F
+
F
A possibly const qualified Deferred Callable Object type
-
A1
- ...AN
+
A1
+ ...AN
Argument types
-
a1
- ...aN
+
a1
+ ...aN
- Objects or references to objects with types A1
- ...AN
+ Objects or references to objects with types A1
+ ...AN
-
T1
- ...TN
+
T1
+ ...TN
- Ti is Ai &
- if ai is an LValue,
- same as Ai, otherwise
+ Ti is Ai &
+ if ai is an LValue,
+ same as Ai, otherwise
- A non-member-pointer Callable
+ A non-member-pointer Callable
Object type: A pointer to a function or a class type whose objects
can appear immediately to the left of a function call operator.
If the target function is a pointer to a class members, the corresponding
object can be specified as a reference, pointer, or smart pointer. In
- case of the latter, a freestanding get_pointer function
- must be defined (Boost provides this function for std::auto_ptr
- and boost::shared_ptr).
+ case of the latter, a freestanding get_pointer function
+ must be defined (Boost provides this function for std::auto_ptr
+ and boost::shared_ptr).
- Return type: Return type of f when invoked with the elements in
- s as its arguments.
+ Return type: Return type of f when invoked with the elements in
+ s as its arguments.
- Semantics: Invokes f
- with the elements in s
+ Semantics: Invokes f
+ with the elements in s
as arguments and returns the result of the call expression.
- Return type: Return type of f when invoked with the elements in
- s as its arguments.
+ Return type: Return type of f when invoked with the elements in
+ s as its arguments.
- Semantics: Invokes f
- with the elements in s
+ Semantics: Invokes f
+ with the elements in s
as arguments and returns the result of the call expression.
For pointers to class members corresponding object can be specified as
a reference, pointer, or smart pointer. In case of the latter, a freestanding
- get_pointer function must be defined (Boost provides
- this function for std::auto_ptr and boost::shared_ptr).
+ get_pointer function must be defined (Boost provides
+ this function for std::auto_ptr and boost::shared_ptr).
The target function must not be a pointer to a member object (dereferencing
@@ -54,7 +52,7 @@
isn't implemented).
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,
+ hold a specific type. A vector<int>
+ can only hold ints. A list<X> can
+ only hold elements of type X,
and so on.
@@ -41,8 +42,8 @@
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,
+ 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
@@ -51,7 +52,7 @@
The Boost.Tuple
library written by Jaakko
- Jarvi provides heterogeneous containers in C++. The tuple
+ 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
@@ -89,23 +90,23 @@
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
+ 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
+ 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
+ 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.
- Return type: A model of the same iterator
- concept as 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
+ Semantics: Returns an iterator to the
+ element M positions from
+ i. If i
+ is a Bidirectional
+ Iterator then M
may be negative.
- Return type: A model of the same iterator
- concept as 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
+ Semantics: Returns an iterator to the
+ element N positions from
+ i. If i
+ is a Bidirectional
+ Iterator then N
may be negative.
- Return type: A model of the same iterator
- concept as I.
+ 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
+ Semantics: Returns an iterator a distance
+ M from I.
+ If I is a Bidirectional
+ Iterator then M
may be negative.
- Return type: A model of the same iterator
- concept as I.
+ 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.
+ 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.
- Semantics: Returns boost::mpl::true_
- if I and J are iterators to the same position.
- Returns boost::mpl::false_ otherwise.
+ Semantics: Returns boost::mpl::true_
+ if I and J are iterators to the same position.
+ Returns boost::mpl::false_ otherwise.
- Return type: A model of the same iterator
- concept as I.
+ Return type: A model of the same iterator
+ concept as I.
- Semantics: Returns an iterator to the
- next element in the sequence after I.
+ Semantics: Returns an iterator to the
+ next element in the sequence after I.
- Return type: A model of the same iterator
- concept as I.
+ Return type: A model of the same iterator
+ concept as I.
- Semantics: Returns an iterator to the
- previous element in the sequence before I.
+ Semantics: Returns an iterator to the
+ previous element in the sequence before I.
- Semantics: Returns the type stored in
- a sequence at iterator position I.
+ Semantics: Returns the type stored in
+ a sequence at iterator position I.
- Return type: Convertible to bool.
+ 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.
+ Semantics: Equivalent to result_of::equal_to<I,J>::value
+ where I and J are the types of i
+ and j respectively.
- Return type: Convertible to bool.
+ 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.
+ Semantics: Equivalent to !result_of::equal_to<I,J>::value
+ where I and J are the types of i
+ and j respectively.
- An interesting peculiarity of functions like at when applied to a Forward
- Sequence like list
+ 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.
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 typek. The compiler chooses the appropriate function
- given a key, k.
+ constant compile time complexities. There is an overloaded function, f(k), for each key typek. The compiler chooses the appropriate function
+ given a key, k.
Tag dispatching is a generic programming technique for selecting template specializations.
There are typically 3 components involved in the tag dispatching mechanism:
@@ -70,7 +69,7 @@
- For example, the fusion result_of::begin metafunction
+ For example, the fusion result_of::begin metafunction
is implemented as follows:
@@ -88,24 +87,24 @@
-Sequence is the type for
- which a suitable implementation of result_of::begin_impl
+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
+traits::tag_of is the metafunction that associates
+ Sequence with an appropriate
tag
-result_of::begin_impl is the template which is specialized
+result_of::begin_impl is the template which is specialized
to provide an implementation for each tag type
Unlike MPL, there
is no extensibe sequence concept in fusion. This does not mean that Fusion
@@ -115,13 +114,13 @@
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
+ 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.
+ push_back does not actually
+ mutate an mpl::vector. It can't do that. Instead, it returns
+ an extended mpl::vector.
Like MPL, Fusion
@@ -131,51 +130,51 @@
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
+ 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.
- Functions that take in elemental values to form sequences (e.g. make_list) convert their arguments
+ 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:
- Fusion's generation functions (e.g. make_list) by default stores the element
+ Fusion's generation functions (e.g. make_list) by default stores the element
types as plain non-reference types. Example:
- Sometimes the plain non-reference type is not desired. You can use boost::ref
- and boost::cref to store references or const references
+ 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:
@@ -225,11 +224,11 @@
[14]
Note that the type of a string literal is an array of const characters,
- not constchar*. 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).
+ not constchar*. 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).
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
@@ -33,10 +34,10 @@
- The entire library is found in the "boost/fusion"
+ 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"
+ there exists "boost/fusion/support.hpp"
in the same directory as "boost/fusion/support". Everything, except
those found inside "detail" directories, is public.
- There is also a "boost/fusion/include/"
+ There is also a "boost/fusion/include/"
directory that contains all the headers to all the components and modules.
If you are unsure where to find a specific component or module, or don't want
to fuss with hierarchy and nesting, use this.
@@ -64,10 +65,10 @@
The library is header-only. There is no need to build object files to link
against.
- If, for example, you want to use list,
+ If, for example, you want to use list,
depending on the granularity that you desire, you may do so by including one
of
Fusion is a library for working with heterogenous collections of data, commonly
referred to as tuples. A set of containers (vector, list, set and map) is provided,
@@ -61,10 +62,10 @@
It is named "fusion" because the library is a "fusion"
of compile time metaprogramming with runtime programming.
Tuples are powerful beasts. After having developed two significant projects
(Spirit and Phoenix)
@@ -87,17 +88,17 @@
had an adhoc collection of tuple manipulation and traversal routines. It was
an instant AHA! moment.
I assume the reader is already familiar with tuples (Boost.Tuple)
- and its ancestor std::pair. The tuple is a generalization of std::pair
+ 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.
+ is more or less a synonym for fusion's vector.
For starters, we shall include all of Fusion's Sequence(s)
- [1]
+ [1]
:
- Just replace tuple for vector
- and get for at_c and this is exactly like
+ 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.
+ there. You can do a lot more with Fusion vector or tuple.
Let's see some examples.
- That's it! for_each is a fusion algorithm.
+ 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.
+ 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
+
+ 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
+ for_each is generic. With
+ print_xml, you can use it to
print just about any Fusion Sequence.
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
+ which are pointers. Ah, easy. First, let's include the is_pointer
boost type trait:
- filter_if is another Fusion
- algorithm. It returns a filter_view, a conforming Fusion sequence.
+ 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
+ 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.
- Apart from vector,
+ 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
+ its own characteristics. We have list, set, map, plus a multitude of views that provide various ways to present
the sequences.
- Fusion's map
+ Fusion's map
associate types with elements. It can be used as a cleverer replacement of
- the struct. Example:
+ the struct. Example:
- map
+ map
is an associative sequence. Its elements are Fusion pairs which differ somewhat
- from std::pair. Fusion pairs only contain one member,
+ 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:
+ For example, given a a_person
+ of type, person, you can do:
- Why go through all this trouble, you say? Well, for one, unlike the struct, we are dealing with a generic data structure.
+ 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.
+ maps.
Example:
- 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.
+ 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.
And... we've barely scratched the surface! You can compose and expand the data
structures, remove elements from the structures, find specific data types,
@@ -238,14 +239,14 @@
[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
+
[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.
- The Associative
+ The Associative
Sequence concept is orthogonal to traversal. An Associative Sequence
allows efficient retrieval of elements based on keys.
- s is mutable and
- e=
- o, where e is the first element in the
+ s is mutable and
+ e=
+ o, where e is the first element in the
sequence, is a valid expression.
+ 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
+ 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>.
-
- 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.
+ 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.
- s is mutable and
- e=
- o, where e is the first element in the
+ s is mutable and
+ e=
+ o, where e is the first element in the
sequence, is a valid expression.
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.
@@ -43,29 +41,29 @@
- s is mutable and
- e=
- o, where e is the first element in the
+ s is mutable and
+ e=
+ o, where e is the first element in the
sequence, is a valid expression.
- A boolean Integral Constant c
- such that c::value==
- true if and only if the
- sequence is empty; see empty.
+ A boolean Integral Constant c
+ such that c::value==
+ true if and only if the
+ sequence is empty; see empty.
For any Forward Sequence s the following invariants always hold:
-[begin(s),end(s)) is always a valid range.
+[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.
+ 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.
+begin(s)
+ is identical to end(s))
+ if and only if s is empty.
- Two different iterations through s
+ Two different iterations through s
will access its elements in the same order.
- s is mutable and
- e=
- o, where e is the first element in the
+ s is mutable and
+ e=
+ o, where e is the first element in the
sequence, is a valid expression.
- result_of::at<S,N> returns the actual type returned by
- at<N>(s). In
+
+
+
+ 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
+ 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>.
-
@@ -37,20 +37,20 @@
Intrinsic functions, unlike Algorithms,
are not generic across the full Sequence
repertoire. They need to be implemented for each Fusion Sequence
- [4]
+ [4]
.
-
- 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
+ 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.
- 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
+ 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.
- Return type: Returns a reference to
- the element associated with Key from the sequence seq
- if seq is mutable and
- e=
- o, where e
+ 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.
- Return type: Returns a reference to
- the last element in the sequence seq
- if seq is mutable and
- e=
- o, where e
+ 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.
- Returns a type convertible to bool
- that evaluates to true if
- the sequence is empty, else, evaluates to false.
+ Returns a type convertible to bool
+ that evaluates to true if
+ the sequence is empty, else, evaluates to false.
- Return type: Convertible to bool.
+ Return type: Convertible to bool.
- Semantics: Evaluates to true if the sequence is empty, else, evaluates
- to false.
+ Semantics: Evaluates to true if the sequence is empty, else, evaluates
+ to false.
- Return type: Returns a reference to
- the first element in the sequence seq
- if seq is mutable and
- e=
- o, where e
+ 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.
- Returns a type convertible to bool
- that evaluates to true if
+ Returns a type convertible to bool
+ that evaluates to true if
the sequence contains an element associated with a Key, else, evaluates
- to false.
+ to false.
- Return type: Convertible to bool.
+ Return type: Convertible to bool.
- Semantics: Evaluates to true if the sequence contains an element
- associated with Key, else, evaluates to false.
+ Semantics: Evaluates to true if the sequence contains an element
+ associated with Key, else, evaluates to false.
- Semantics: Calls swap(a1,b1) for corresponding elements in seq1 and seq2.
+ Semantics: Calls swap(a1,b1) for corresponding elements in seq1 and seq2.
- Semantics: Returns the result type of
- using at to access the Nth element of Seq.
+ Semantics: Returns the result type of
+ using at to access the Nth element of Seq.
[5]
- 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
+
[5]
+ 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
- Semantics: Returns the result type of
- using at_c to access the Mth element of Seq.
+ Semantics: Returns the result type of
+ using at_c to access the Mth element of Seq.
[6]
- 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
+
[6]
+ 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
- Semantics: Returns the result of using
- at_key to access the element
- with key type Key in
- Seq.
+ Semantics: Returns the result of using
+ at_key to access the element
+ with key type Key in
+ Seq.
[7]
- 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
+
[7]
+ 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
- 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.
+ 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.
- Return type: An iterator modelling the
- same traversal concept as Seq.
+ Return type: An iterator modelling the
+ same traversal concept as Seq.
- Semantics: Returns the type of an iterator
- to the first element of Seq.
+ Semantics: Returns the type of an iterator
+ to the first element of Seq.
- Semantics: Returns mpl::true_
- if Seq has zero elements,
- mpl::false_ otherwise.
+ Semantics: Returns mpl::true_
+ if Seq has zero elements,
+ mpl::false_ otherwise.
- 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.
+ 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.
- Semantics: Returns mpl::true_
- if Seq contains an element
- with key type Key, returns
- mpl::false_ otherwise.
+ Semantics: Returns mpl::true_
+ if Seq contains an element
+ with key type Key, returns
+ mpl::false_ otherwise.
- Semantics: Returns the actual element
- type associated with key type Key
- in Seq.
+ Semantics: Returns the actual element
+ type associated with key type Key
+ in Seq.
- The Comparison operators: ==,
- !=, <,
- <=, >=
- and >= work generically
+ 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.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a==b is a valid expression returning a
+ 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.
@@ -114,18 +114,18 @@
compile time error.
- Semantics:
+ 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
+ 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.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a<b is a valid expression returning a
+ 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.
@@ -114,10 +111,10 @@
compile time error.
- Semantics: Returns b < a.
+ Semantics: Returns b < a.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a<b is a valid expression returning a
+ 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.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a<b is a valid expression returning a
+ 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.
@@ -114,12 +111,12 @@
compile time error.
- Semantics: Returns the lexicographical
- comparison of between a
- and b.
+ Semantics: Returns the lexicographical
+ comparison of between a
+ and b.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a<b is a valid expression returning a
+ 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.
- For each element, e1,
- in sequence a, and for
- each element, e2, in
- sequence b, a==b is a valid expression returning a
+ 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.
- The I/O operators: <<
- and >> work generically
- on all Fusion sequences. The global operator<< has been overloaded for generic
+ 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>>
+ 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.
+ 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:
- outputs the vector
+ outputs the vector
as: (1.0 2 Howdy folks!)
@@ -57,23 +58,23 @@
Manipulators
-
tuple_open(arg)
+
tuple_open(arg)
Defines the character that is output before the first element.
-
tuple_close(arg)
+
tuple_close(arg)
Defines the character that is output after the last element.
-
tuple_delimiter(arg)
+
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,
+ The argument to tuple_open,
+ tuple_close and tuple_delimiter may be a char, wchar_t,
a C-string, or a wide C-string.
- outputs the same vector, 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
+ The same manipulators work with operator>> and istream
+ as well. Suppose the std::cin
stream contains the following data:
- reads the data into the vector(s) i
- and 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
+ with std::string or C-style string elements does
not generally work, since the streamed Sequence
representation may not be unambiguously parseable.
- It removes references to const,
- references to array types are kept, even if the array is const.
- Reference wrappers are removed (see boost::ref).
+ It removes references to const,
+ references to array types are kept, even if the array is const.
+ Reference wrappers are removed (see boost::ref).
- Metafunction that evaluates to mpl::true_
- if a certain type T is a
- conforming Fusion Sequence, mpl::false_
+ 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.
- Semantics: Metafunction that evaluates to
- mpl::true_ if a certain type T
- is a conforming Fusion sequence, mpl::false_
+ Semantics: Metafunction that evaluates to
+ mpl::true_ if a certain type T
+ is a conforming Fusion sequence, mpl::false_
otherwise.
- Metafunction that evaluates to mpl::true_
- if a certain type T is a
- conforming Fusion View, mpl::false_
+ 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
+ reference. is_view may be
specialized to accomodate clients providing Fusion conforming views.
- Semantics: Metafunction that evaluates to
- mpl::true_ if a certain type T
- is a conforming Fusion view, mpl::false_
+ Semantics: Metafunction that evaluates to
+ mpl::true_ if a certain type T
+ is a conforming Fusion view, mpl::false_
otherwise.
- Fusion pair type is a half
- runtime pair. A half runtime pair is similar to a std::pair,
- but, unlike std::pair,
+ 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.
- The type of the first template parameter, F,
- equivalent to result_of::first<P>::type.
+ The type of the first template parameter, F,
+ equivalent to result_of::first<P>::type.
- P::second_type
+ P::second_type
- The type of the second template parameter, S,
- equivalent to result_of::second<P>::type.
+ The type of the second template parameter, S,
+ equivalent to result_of::second<P>::type.
- P()
+ P()
@@ -202,37 +203,37 @@
- P(s)
+ P(s)
- Construct a pair given value for the second type, s.
+ Construct a pair given value for the second type, s.
- P(p2)
+ P(p2)
- Copy constructs a pair from another pair, p2.
+ Copy constructs a pair from another pair, p2.
- p=
- p2
+ p=
+ p2
- Assigns a pair, p1, from another pair, p2.
+ Assigns a pair, p1, from another pair, p2.
@@ -244,45 +245,45 @@
- Make a pair given the first type, F,
- and a value for the second type, s.
- The second type assumes the type of 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
+ o<<
+ p
- Output p to output
- stream, o.
+ Output p to output
+ stream, o.
- i>>
- p
+ i>>
+ p
- Input p from input
- stream, i.
+ Input p from input
+ stream, i.
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
+ 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
+ Tuple interface, and the extended uses of std::pair described
in the TR1 document.
Fusion's implementation of the TR1
- Tuple is also a fusion Forward
+ 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
+ Currently tuple is basically a synonym for vector, although this may be changed
in future releases of fusion.
The TR1
Tuple type provides a default constructor, a constructor that takes
@@ -37,34 +37,34 @@
copy constructor. The details of the various constructors are described
in this section.
- The type of the ith
+ The type of the ith
element of a tuple
-
Pi
+
Pi
- The type of the ith
+ The type of the ith
parameter
@@ -73,48 +73,48 @@
tuple();
- Requirements: Each Ti
+ Requirements: Each Ti
is default constructable.
- Semantics: Default initializes each element
+ Semantics: Default initializes each element
of the tuple.
tuple(P1,P2,...,PN);
- Requirements: Each Pi
- is Ti if Ti is a reference type, constTi& otherwise.
+ Requirements: Each Pi
+ is Ti if Ti is a reference type, constTi& otherwise.
- Semantics: Copy initializes each element
+ Semantics: Copy initializes each element
with the corresponding parameter.
tuple(consttuple&t);
- Requirements: Each Ti
+ Requirements: Each Ti
should be copy constructable.
- Semantics: Copy constructs each element
- of *this
- with the corresponding element of t.
+ Semantics: Copy constructs each element
+ of *this
+ with the corresponding element of t.
- Requirements: Each Ti
- shall be constructible from the corresponding Ui.
+ Requirements: Each Ti
+ shall be constructible from the corresponding Ui.
- Semantics: Constructs each element of
- *this
- with the corresponding element of t.
+ Semantics: Constructs each element of
+ *this
+ with the corresponding element of t.
- Requires: 0
+ Requires: 0<I
- <=N.
- The program is ill formed if I
- is out of bounds. T is
- any fusion sequence type, including tuple.
+ <=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.
+ Return type: RJ
+ is equivalent to result_of::at_c<I,T>::type.
- Returns: A reference to the Ith element of T.
+ Returns: A reference to the Ith element of T.
template<intI,typenameT>PJget(Tconst&t);
- Requires: 0
+ Requires: 0<I
- <=N.
- The program is ill formed if I
- is out of bounds. T is
- any fusion sequence type, including tuple.
+ <=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.
+ Return type: PJ
+ is equivalent to result_of::at_c<I,T>::type.
- Returns: A const reference to the Ith element of T.
+ Returns: A const reference to the Ith element of T.
- Requirements: For all i,
- 1<=
+ 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.
+ 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.
+ 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.
- Requirements: For all i,
- 1<=
+ 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.
+ 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.
+ Semantics: Returns the lexicographical
+ comparison of between lhs
+ and rhs.
- Requirements: For all i,
- 1<=
+ 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.
+ N, get<i>(lhs)==get<i>(rhs)
+ is a valid expression returning a type that is convertible to bool.
- Requirements: For all i,
- 1<=
+ 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.
+ N, get<i>(rhs)<get<i>(lhs)
+ is a valid expression returning a type that is convertible to bool.
- Requirements: For all i,
- 1<=
+ 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.
+ N, get<i>(rhs)<get<i>(lhs)
+ is a valid expression returning a type that is convertible to bool.
- Requirements: For all i,
- 1<=
+ 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.
+ N, get<i>(lhs)<get<i>(rhs)
+ is a valid expression returning a type that is convertible to bool.
- TR1 describes 2 utility functions for creating _tr1tuple_s. make_tuple
- builds a tuple out of it's argument list, and tie
+ 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.
- Where Vi is X&
- if the cv-unqualified type Ti
- is reference_wrapper<X>,
- otherwise Vi is Ti.
+ Where Vi is X&
+ if the cv-unqualified type Ti
+ is reference_wrapper<X>,
+ otherwise Vi is Ti.
- Returns: tuple<T1&, T2&, ...,
- TN&>(t1, t2, ..., tN). When argument ti
- is ignore, assigning any
+ 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.
- Value: The number of elements in the sequence.
- Equivalent to result_of::size<T>::type.
+ 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<=
+ Requires: T
+ is any fusion sequence type, including tuple.
+ 0<=I<
- N or the program is ill formed.
+ 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.
+ Value: The type of the Ith
+ element of T. Equivalent
+ to result_of::value_at<I,T>::type.
The TR1
- Tuple interface is specified to provide uniform access to std::pair
+ Tuple interface is specified to provide uniform access to std::pair
as if it were a 2 element tuple.
- Type: If I
- ==0
- P is T1,
- else if I==
- 1P
- is T2 else the program is
+ Type: If I
+ ==0
+ P is T1,
+ else if I==
+ 1P
+ 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.
+ Returns: pr.first
+ if I==
+ 0 else pr.second.[*Returns:
+ pr.first if I
+ ==0
+ else pr.second.
- filter_view is a view into
+ 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_.
+ The filter_view presents
+ only those elements for which its predicate evaluates to mpl::true_.
- reverse_view presents a reversed
+ reverse_view presents a reversed
view of underlying sequence. The first element will be its last and the last
element will be its first.
- The unary version of transform_view
+ The unary version of transform_view
presents a view of its underlying sequence given a unary function object
- or function pointer. The binary version of transform_view
+ or function pointer. The binary version of transform_view
presents a view of 2 underlying sequences, given a binary function object
- or function pointer. The transform_view
+ or function pointer. The transform_view
inherits the traversal characteristics (see Sequence
Traversal Concept) of its underlying sequence or sequences.
- A unary function object or function pointer. boost::result_of<F1(E)>::type is the return type of an instance
- of F1 when called
- with a value of each element type E
+ A unary function object or function pointer. boost::result_of<F1(E)>::type is the return type of an instance
+ of F1 when called
+ with a value of each element type E
in the input sequence.
@@ -164,14 +162,14 @@
- F2
+ F2
- A binary function object or function pointer. boost::result_of<F2(E1,E2)>::type is the return type of an instance
- of F2 when called
- with a value of each corresponding pair of element type E1 and E2
+ A binary function object or function pointer. boost::result_of<F2(E1,E2)>::type is the return type of an instance
+ of F2 when called
+ with a value of each corresponding pair of element type E1 and E2
in the input sequences.
- Creates a unary transform_view
- given sequence, s
- and unary function object or function pointer, f1.
+ Creates a unary transform_view
+ given sequence, s
+ and unary function object or function pointer, f1.
- BTV(s1,s2,f2)
+ BTV(s1,s2,f2)
- Creates a binary transform_view
- given sequences, s1
- and s2 and binary
- function object or function pointer, f2.
+ Creates a binary transform_view
+ given sequences, s1
+ and s2 and binary
+ function object or function pointer, f2.
- TV(tv)
+ TV(tv)
- Copy constructs a transform_view
- from another transform_view,
- tv.
+ Copy constructs a transform_view
+ from another transform_view,
+ tv.
- tv=
- tv2
+ tv=
+ tv2
- Assigns to a transform_view,
- tv, from another
- transform_view,
- tv2.
+ Assigns to a transform_view,
+ tv, from another
+ transform_view,
+ tv2.
- zip_view presents a view
+ zip_view presents a view
which iterates over a collection of Sequence(s)
- in parallel. A zip_view is
+ in parallel. A zip_view is
constructed from a Sequence of references
to the component _sequence_s.