Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::mpl::max_element and boost::mpl::vector
From: peter_foelsche_at_[hidden]
Date: 2008-09-30 15:14:35


I figured it out myself:

        template<typename CDB, typename CDB1>
        struct CTargetEqualOrGreater
        { typedef CTargetEqualOrGreater<CDB, CDB1> type;
                typedef typename boost::mpl::transform<
                        CDB,
                        CDB1,
                        boost::mpl::not_<
                                boost::mpl::or_<
                                        boost::mpl::and_<
                                                boost::mpl::not_<boost::mpl::_1>,
                                                boost::mpl::not_<boost::mpl::_2>
>,
                                        boost::mpl::_1
>
>
>::type CBoolVector;
                typedef typename boost::mpl::max_element<CBoolVector>::type CMaxElement;
                typedef typename boost::mpl::deref<CMaxElement>::type CDeRef;
                static const bool value = CDeRef::value == false;
        };

-----Original Message-----
From: FOELSCHE,PETER (A-SantaClara,ex1)
Sent: Tuesday, September 30, 2008 11:53
To: 'boost-users_at_[hidden]'
Subject: [Boost-users] boost::mpl::max_element and boost::mpl::vector

I have two vectors (CDB and CDB1) containing boolean.
I want to make certain that if a bit in the second vector is set,
it must also be set in the first vector.

        template<typename CDB, typename CDB1>
        struct CTargetEqualOrGreater
        { static const bool value = boost::mpl::deref<
                        boost::mpl::max_element<
                                boost::mpl::transform<
                                        CDB,
                                        CDB1,
                                        boost::mpl::not_<
                                                boost::mpl::or_<
                                                        boost::mpl::and_<
                                                                boost::mpl::not_<boost::mpl::_1>,
                                                                boost::mpl::not_<boost::mpl::_2>
>,
                                                        boost::mpl::_1
>
>
>
>
>::type::value == 0;
        };

...
BOOST_MPL_ASSERT( (CTargetEqualOrGreater<CDB, CDB1>::value));

But this does not compile.


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