Boost logo

Boost Users :

From: Noel Belcourt (kbelco_at_[hidden])
Date: 2005-10-02 12:15:34


On Oct 1, 2005, at 6:57 PM, David Abrahams wrote:

> "Noel Belcourt" <kbelco_at_[hidden]> writes:
>> So if I want to perform an element-wise mpl::or operation of two
>> sequences (r, p1) and then test the resulting sequence for equivalence
>> to the input sequence, something like this should work since as you
>> observe below, mpl::equal will compare two sequences and yield a
>> scalar
>> boolean.
>
> BOOST_MPL_ASSERT((equal<r, transform<r, p1, or_<_,_> >::type>));

One more observation about this, this code doesn't compile if r and p1
are a vector_c<bool,..> or a vector_c<int,..> with CW 9.5 on Tiger
10.4.2. The compiler output is attached.

For example, if r and p1 are declared as follows, the code will not
compile.

typedef vector_c<bool,1,0> r,p1;
BOOST_MPL_ASSERT(( equal<r, transform<r, p1, or_<_,_> >::type>));

The problem seems to be that the sequence produced by invoking
transform using a boolean binary function is a different type than
vector_c<bool,..>. The fix is trivial.

typedef vector_c<bool,1,0> r,p1;
BOOST_MPL_ASSERT(( equal<transform<r, r, and_<_,_> >::type,
transform<r, p1, or_<_,_> >::type>));

While clunky, this works, and also works if we declare r and p1 as
vector_c<int,..>.

Just want to be sure that this is known and expected behavior?

> BOOST_MPL_ASSERT((
> equal_to<
> find<
> zip_view<r,p1>
> , not_equal_to<first<_>,or_<first<_>,second<_> >
>> ::type
> , end<zip_view<r,p1> >::type
>>
> ))

I'll be sure to read up on zip_view and try this out.

Thanks for your help.

-- Noel





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