Boost logo

Boost Users :

Subject: [Boost-users] [fusion] iterating over a sequence with non-const references
From: paul Fultz (pfultz2_at_[hidden])
Date: 2012-03-31 14:08:57


Hi, I would like to iterate over a sequence and preserve the reference/const/non-const of the elements. That is say I have a sequence like this:     tuple<int&, int> seq; I would like to this to be true:     typeof(deref(begin(seq))) == int&     typeof(deref(next(begin(seq)))) == int&& It seems fusion sequences always return a const reference to the element. Is there a workaround to get it to work like this? Or is this just not possible with Boost.Fusion? Furthermore, I would like to use the transformation algorithms (especially push_back, and push_front) and still preserve the reference type. Is that possible, through some workarounds? Finally, would it still be fairly efficient when dealing with references, to copy the tuple and make a new tuple when doing algorithms such as push_back or push_front? Or is the lazy evaluation much more efficient than that? Thanks, Paul Fultz II


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net