Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users] Cartesian product
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-10-26 17:44:26

On 10/26/11 12:12, Christoph Heindl wrote:
> On Wed, Oct 26, 2011 at 5:34 PM, Larry Evans <cppljevans_at_[hidden]> wrote:
>> [...]
>> shows how to do this where values in the containers are all same type.
>> It works by simply keeping a vector of loop indices or iterators.
>> During the operator++, it checks which which iterator to increment,
>> and if that is at the end, then it moves to the next iterator.
>> Dereferencing all the iterators should give 1 element in the
>> cross product. I would think that simply changing the vector
>> of loop indices to a fusion vector of those indices would enable
>> the same to be done containers of different types.
> Thanks for the hint.
> Actually I have something similar up and running based on code from
> stackoverflow. My problem stems from missing meta-programming skills.
> For example if we go for boost fusion, then how to get the value_type
> of the boost fusion vector corresponding to tuple<....>, etc...
> Best regards,
> Christoph
The attached code produces output:

:i= 0:(type_u<0>=0 type_u<1>=0 type_u<2>=0)
:i= 1:(type_u<0>=0 type_u<1>=0 type_u<2>=1)
:i= 2:(type_u<0>=0 type_u<1>=0 type_u<2>=2)
:i= 3:(type_u<0>=0 type_u<1>=1 type_u<2>=0)
:i= 4:(type_u<0>=0 type_u<1>=1 type_u<2>=1)
:i= 5:(type_u<0>=0 type_u<1>=1 type_u<2>=2)
:i= 6:(type_u<0>=1 type_u<1>=0 type_u<2>=0)
:i= 7:(type_u<0>=1 type_u<1>=0 type_u<2>=1)
:i= 8:(type_u<0>=1 type_u<1>=0 type_u<2>=2)
:i= 9:(type_u<0>=1 type_u<1>=1 type_u<2>=0)
:i= 10:(type_u<0>=1 type_u<1>=1 type_u<2>=1)
:i= 11:(type_u<0>=1 type_u<1>=1 type_u<2>=2)
:i= 12:(type_u<0>=2 type_u<1>=0 type_u<2>=0)
:i= 13:(type_u<0>=2 type_u<1>=0 type_u<2>=1)
:i= 14:(type_u<0>=2 type_u<1>=0 type_u<2>=2)
:i= 15:(type_u<0>=2 type_u<1>=1 type_u<2>=0)
:i= 16:(type_u<0>=2 type_u<1>=1 type_u<2>=1)
:i= 17:(type_u<0>=2 type_u<1>=1 type_u<2>=2)

Compilation finished at Wed Oct 26 16:38:59

Is this what you want?

It uses the g++ variadic templates compiler:

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at