"Noel Belcourt" <kbelco@sandia.gov> writes:
On Oct 1, 2005, at 6:57 PM, David Abrahams wrote:
"Noel Belcourt" <kbelco@sandia.gov> 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,..>.
I think that's not really the issue. I think the problem is that the _element_ types of those two sequuences are not identical.
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,..>.
Actually I think that's technically nonportable. I'm guessing the right thing to do is use find, one way or the other. This is typedef transform<r, p1, not_equal_to<_1, or_<_,_> > >::type x; BOOST_MPL_ASSERT(( is_same< find_if<x,_1>::type , end_<x>::type > ));
Just want to be sure that this is known and expected behavior?
I'm actually unsure. Aleksey?
BOOST_MPL_ASSERT(( equal_to<
I think this should be is_same. Sorry for the mistake.
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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Dave Abrahams Boost Consulting www.boost-consulting.com