Boost logo

Boost :

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


Hi,

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
in http://aspn.activestate.com/ASPN/Mail/Message/1387917.

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.

Sincerely,

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
>::type,
        typename mpl::equal_to< typename Signature::rhs_index, RhsIndex
>::type
>::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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk