
----- Original Message -----
From: "Joel de Guzman"
vicente.botet wrote:
Hi,
What is the reason fusion::transform taskes a const Sequence? template< typename Sequence, typename F > typename result_of::transform
::type transform( Sequence const& seq, F f); Does this means that the transform do not change the sequence itself o also its elements?
Yes. Fusion transform returns a lazy (transform) view. This view is non-mutating. It is not like STL's transform which mutates the target container in place. Fusion's is purely functional and lazily evaluated.
Can for_each mutate the sequence elements? if yes, would the following get a transformation I'm locking for?
vector
boost::tuple
= ??(boost::fusion::transform(t, get())); boost::as_vector? Is there a as_tuple function? Should this force the evaluation of the get function? As I said, Fusion transform is purely functional. The result of a transform is a view. The function will only be called when you iterate over the view. The transformation does not change/mutate the sequence itself. If that's what you want, you can assign the view back to the original container. For example:
vector
v; v = transform(v, f);
I was lock for in the documentation and I have not found this assignation. Where in the documentation can I found that I can do that? If for_each can change/mutate the sequence itself, why don't have a mutating_transform that takes a Sequence& and not a Sequence const& Just a last question. How move semantics maps with purely functional Sequences? Do you plan to add move semantics for the elements of the tuple? The concept of MovableSequence has a sens for you? Thanks, Vicente