[fusion] incremental zipping

Hi, I am zipping fusion sequences in a series of incremental zip operations: zip(zip(zip(a,b),c),...) as a result I am getting sequence with elements like: vector2<vector2<vector2<a[i],b[i]>,c[i]>,...> what I want instead is that elements would look like: vector<a[i],b[i],c[i],...> What the simplest way to achieve this? Gennadiy

Gennadiy Rozental <rogeeff@gmail.com> writes:
Hi,
I am zipping fusion sequences in a series of incremental zip operations:
zip(zip(zip(a,b),c),...)
as a result I am getting sequence with elements like:
vector2<vector2<vector2<a[i],b[i]>,c[i]>,...>
what I want instead is that elements would look like:
vector<a[i],b[i],c[i],...>
What the simplest way to achieve this?
--8<---------------cut here---------------start------------->8--- #include <boost/fusion/algorithm/transformation/push_back.hpp> #include <boost/fusion/container/vector.hpp> #include <boost/fusion/container/generation.hpp> #include <boost/fusion/sequence/io.hpp> #include <boost/fusion/view/zip_view.hpp> #include <iostream> int main() { using namespace boost::fusion; vector<int,int> a(0,1),b(1,2),c(2,3); auto v=push_back( push_back( push_back( make_vector(),boost::ref(a)),boost::ref(b)),boost::ref(c)); auto z=zip_view<decltype(v)>(v); std::cout << z << std::endl; } --8<---------------cut here---------------end--------------->8--- Christopher

Christopher Schmidt <mr.chr.schmidt <at> online.de> writes:
auto v=push_back( push_back( push_back( make_vector(),boost::ref(a)),boost::ref(b)),boost::ref(c)); auto z=zip_view<decltype(v)>(v);
This is not what I want. Let @ denote zipping operation. I want: x = a @ b // x == ((0,1),(1,2)) ... y = x @ c // y = ((0,1,2),(1,2,3)) Right now I am getting y = (((0,1),2),((1,2),3)) Gennadiy P.S. You example does not work for me push_back.hpp does not build under MSVC10

On 11/20/2011 6:44 AM, Gennadiy Rozental wrote:
Christopher Schmidt <mr.chr.schmidt <at> online.de> writes:
auto v=push_back( push_back( push_back( make_vector(),boost::ref(a)),boost::ref(b)),boost::ref(c)); auto z=zip_view<decltype(v)>(v);
This is not what I want. Let @ denote zipping operation. I want:
x = a @ b // x == ((0,1),(1,2)) ... y = x @ c // y = ((0,1,2),(1,2,3))
Right now I am getting y = (((0,1),2),((1,2),3))
Gennadiy
P.S. You example does not work for me push_back.hpp does not build under MSVC10
Builds fine with me using both VC2010 and g++. Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

Joel de Guzman <joel <at> boost-consulting.com> writes:
Builds fine with me using both VC2010 and g++.
After I just include this: #include <boost/fusion/algorithm/transformation/push_back.hpp> I am getting this from express edition: 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(261): error C2146: syntax error : missing ',' before identifier 'push_back' 1> ...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(279) : see reference to class template instantiation 'boost::fusion::detail::make_segment_sequence_back<Stack,Size>' being compiled 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(261): error C2065: 'push_back' : undeclared identifier 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(262): error C2275: 'boost::fusion::detail::make_segment_sequence_back<Stack,Size>::rest_type' : illegal use of this type as an expression 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(262): error C2143: syntax error : missing ',' before 'const' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(265): warning C4517: access-declarations are deprecated; member using-declarations provide a better alternative 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(265): warning C4346: 'boost::fusion::detail::segment_sequence<make_segment_sequence_back<Stack::cdr_ type>::type>::type' : dependent name is not a type 1> prefix with 'typename' to indicate a type 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(265): error C2143: syntax error : missing ';' before '>' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(266): error C2238: unexpected token(s) preceding ';' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(268): error C2146: syntax error : missing ';' before identifier 'call' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(268): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(268): error C2086: 'segment_sequence<make_segment_sequence_back<Stack::cdr_type>::type>::type type' : redefinition 1> ...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(265) : see declaration of 'boost::fusion::detail::make_segment_sequence_back<Stack,Size>::operator type' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(268): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(269): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(278): warning C4183: 'call': missing return type; assumed to be a member function returning 'int' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(394): error C2146: syntax error : missing ',' before identifier 'push_back' 1> ...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(421) : see reference to class template instantiation 'boost::fusion::detail::make_segmented_range_reduce2<StackBegin,StackEnd,SameSe gment>' being compiled 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(394): error C2065: 'push_back' : undeclared identifier 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(399): warning C4346: 'Stack::size::value' : dependent name is not a type 1> prefix with 'typename' to indicate a type 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(399): error C2226: syntax error : unexpected type 'boost::fusion::result_of::push_front<const boost::fusion::iterator_range<result_of::next<StackBegin::car_type::begin_type> ::type,StackEnd::car_type::begin_type>,make_segment_sequence_front<StackBegin> ::type>::type' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(401): warning C4517: access-declarations are deprecated; member using-declarations provide a better alternative 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(401): warning C4346: 'boost::fusion::detail::segment_sequence<make_segment_sequence_back<StackEnd>:: type>::type' : dependent name is not a type 1> prefix with 'typename' to indicate a type 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(401): error C2143: syntax error : missing ';' before '>' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(402): error C2238: unexpected token(s) preceding ';' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(404): error C2146: syntax error : missing ';' before identifier 'call' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(404): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(404): error C2086: 'segment_sequence<make_segment_sequence_back<StackEnd>::type>::type type' : redefinition 1> ...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(401) : see declaration of 'boost::fusion::detail:: make_segmented_range_reduce2<StackBegin,StackEnd,SameSegment>::operator type' 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(404): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(405): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>...\boost\fusion\view\iterator_range\detail\segmented_iterator_range.hpp(420): warning C4183: 'call': missing return type; assumed to be a member function returning 'int' What about original question BTW? Do you have a suggestion? Gennadiy

On 11/20/2011 10:15 AM, Gennadiy Rozental wrote:
Joel de Guzman <joel <at> boost-consulting.com> writes:
Builds fine with me using both VC2010 and g++.
After I just include this: #include <boost/fusion/algorithm/transformation/push_back.hpp>
I am getting this from express edition:
You might want to update from SVN. There's been some recent bug fixes in trunk and release.
What about original question BTW? Do you have a suggestion?
I'll look into it later tonight. I need to understand better what you want. Right now, I'm in Sunday mode ;-) Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

Gennadiy Rozental <rogeeff@gmail.com> writes:
Christopher Schmidt <mr.chr.schmidt <at> online.de> writes:
auto v=push_back( push_back( push_back( make_vector(),boost::ref(a)),boost::ref(b)),boost::ref(c)); auto z=zip_view<decltype(v)>(v);
This is not what I want. Let @ denote zipping operation. I want:
x = a @ b // x == ((0,1),(1,2)) ... y = x @ c // y = ((0,1,2),(1,2,3))
Right now I am getting y = (((0,1),2),((1,2),3))
Gennadiy
P.S. You example does not work for me push_back.hpp does not build under MSVC10
That's a tough questions. You cannot unzip a zip_view, add another sequence, and zip it again. I'd either use transform to flatten the nested zip_view's, or I'd store the sequences separately and rebuild the zip_view every time on the fly. Christopher

Gennadiy Rozental wrote:
Hi,
I am zipping fusion sequences in a series of incremental zip operations:
zip(zip(zip(a,b),c),...)
as a result I am getting sequence with elements like:
vector2<vector2<vector2<a[i],b[i]>,c[i]>,...>
what I want instead is that elements would look like:
vector<a[i],b[i],c[i],...>
What the simplest way to achieve this?
Gennadiy
I think what you want is "deduce_sequence" - it's in the docs Robert Ramey

Robert Ramey <ramey <at> rrsd.com> writes:
Gennadiy Rozental wrote:
zip(zip(zip(a,b),c),...) what I want: vector<a[i],b[i],c[i],...>
I think what you want is "deduce_sequence" - it's in the docs
I am not that well versed in fusion. I do not see how to apply this. can someone show an example? Gennadiy
participants (4)
-
Christopher Schmidt
-
Gennadiy Rozental
-
Joel de Guzman
-
Robert Ramey