"Jaap Suter" <[EMAIL PROTECTED]> writes: > 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.
I think you could rewrite your code to be clearer (see below) but that's not really the problem we're having. The problem is that lambda support requires has_rebind, which instantiates the predicate on its argument. When the argument is a placeholder (arg<N>), it doesn't have ::lhs_index or ::rhs_index members, and the predicate instantiation is an error. I'm looking at it to see if I can find a way to get has_rebind<T> to work without instantiating T. ----- template <class T> struct lhs_index : T::lhs_index { BOOST_MPL_AUX_LAMBDA_SUPPORT(1, lhs_index, (T)); }; template <class T> struct rhs_index : T::rhs_index { BOOST_MPL_AUX_LAMBDA_SUPPORT(1, rhs_index, (T)); }; 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 : mpl::and_< mpl::equal_to<lhs_index<Signature>, LhsIndex> , mpl::equal_to<rhs_index<Signature>, RhsIndex> > { 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; -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost