![]() |
Home | Libraries | People | FAQ | More |
For a sequence seq and
Polymorphic Function
Object F, transform returns a new sequence with
elements created by applying F
to each element of seq.
template<
typename Sequence,
typename F
>
typename result_of::transform<Sequence const, F>::type transform(
Sequence const& seq, F f);
Table 1.55. Parameters
|
Parameter |
Requirement |
Description |
|---|---|---|
|
|
A model of Forward Sequence |
Operation's argument |
|
|
A model of unary Polymorphic
Function Object where |
Transformation function |
transform(seq, f);
Return type: A model of Forward Sequence
Semantics: Returns a new sequence, containing
the return values of f(e) for each element e
within seq.
template<
typename Sequence1,
typename Sequence2,
typename F
>
typename result_of::transform<Sequence1 const, Sequence2 const, F>::type transform(
Sequence1 const& seq1, Sequence2 const& seq2, F f);
Table 1.56. Parameters
|
Parameter |
Requirement |
Description |
|---|---|---|
|
|
A model of Forward Sequence |
Operation's argument |
|
|
A model of Forward Sequence |
Operation's argument |
|
|
A model of binary Polymorphic
Function Object where |
Transformation function |
Return type: A model of Forward Sequence.
Semantics: Returns a new sequence, containing
the return values of f(e1, e2) for each pair of elements e1 and e2
within seq1 and seq2 respectively.
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/transform.hpp>
struct triple { template<typename T> struct result { typedef T type; }; template<typename T> T operator()(T t) const { return t * 3; }; }; ... assert(transform(make_vector(1,2,3), triple()) ==make_vector(3,6,9));
| Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger |