|
Boost : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-03-30 19:45:44
Jaap Suter wrote:
> Hi,
Hi Jaap,
>
> 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>'
It's the same problem we dealt with here -
http://lists.boost.org/MailArchives/boost/msg41700.php. The easiest way to
fix it within the current code base would be this:
template< typename T > struct lhs_index_impl
: T::lhs_index
{
};
template< typename T > struct lhs_index
: mpl::if_<
mpl::is_placeholder<T>
, T
, lhs_index_impl<T>
>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,lhs_index,(T))
};
template< typename T > struct rhs_index_impl
: T::rhs_index
{
};
template< typename T > struct rhs_index
: mpl::if_<
mpl::is_placeholder<T>
, T
, rhs_index_impl<T>
>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,rhs_index,(T))
};
template < class Signature, class LhsIndex, class RhsIndex >
struct predicate
{
typedef typename mpl::and_<
typename mpl::equal_to<
typename lhs_index<Signature>::type, LhsIndex
>::type,
typename mpl::equal_to<
typename rhs_index<Signature>::type, 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;
That's not to say that it's something obvious and easy to figure out - I'll
look if there is a simple way to workaround the compiler's deficiency that
doesn't have this idiosyncrasy.
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk