Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2003-03-30 13:18:19


I apologize, but once again I'm unable to get a lambda expression working
with the MPL.

The code works fine with the Intel and GCC compiler. On MSVC I get the
following error:

    error C2039: 'lhs_index' : is not a member of 'boost::mpl::arg<N>'

The error occurs on the line with the boost static constant. It does not
happen if the template is not instantiated. I have tried using the
AUX_VOID_SPEC macro, but that didn't really help. I even tried closing my
own namespace, and doing an AUX_VOID_SPEC inside the MPL namespace, as done

I also tried deriving predicate from mpl::equal_to that simply compares the
result to true_c, hoping that mpl::equal_to would give me the lambda support
for free. That didn't work either.

Any advice would be greatly appreciated.


Jaap Suter

template < size_t LhsIndex, size_t RhsIndex, int Sign >
struct signature
    typedef mpl::size_t< LhsIndex > lhs_index;
    typedef mpl::size_t< RhsIndex > rhs_index;
    typedef mpl::int_< Sign > type;

template < class Signature, class LhsIndex, class RhsIndex >
struct predicate
    typedef typename mpl::and_<
        typename mpl::equal_to< typename Signature::lhs_index, LhsIndex
        typename mpl::equal_to< typename Signature::rhs_index, RhsIndex
>::type type;

    BOOST_MPL_AUX_LAMBDA_SUPPORT( 3, predicate, (Signature, LhsIndex,
RhsIndex) )

// Test code:

typedef mpl::vector< signature< 1, 1, 1 >,
                                signature< 4, 4, 0 >,
                                signature< 5, 5, 0 >,
                                signature< 4, 5, 1 > > signatures;

typedef mpl::find_if< signatures, predicate< mpl::_1, mpl::size_t< 4 >,
mpl::size_t< 5 > > >::type iter_0;

Boost list run by bdawes at, gregod at, cpdaniel at, john at