
Hi Is it possible to make mpl::at_c lambda-able? For example, the following (dumb) code works as I would expect, but changing "at<_, int_<0> >" at // XXX to "at_c<_, 0>" does not. BOOST_MPL_AUX_LAMBDA_SUPPORT is not in the at_c struct, which is why it doesn't work I assume, but I don't know enough about mpl to know if it can be added (nor how, if so). ---------- #include <boost/mpl/count_if.hpp> #include <boost/mpl/vector.hpp> #include <boost/mpl/vector_c.hpp> #include <boost/mpl/equal_to.hpp> #include <boost/mpl/at.hpp> #include <boost/mpl/int.hpp> int main() { using namespace boost::mpl; typedef vector < vector_c<int, 9>, vector_c<int, 0>, vector_c<int, 6>, vector_c<int, 0> >::type v; BOOST_STATIC_ASSERT((count_if < v, equal_to < int_<0>, at<_, int_<0> > // XXX > >::type::value == 2)); } ---------- thanks, scott

"Scott Graham" <sgraham@gmail.com> writes:
Hi
Is it possible to make mpl::at_c lambda-able?
I'm afraid not. Lambda requires a uniform interface to metafunctions. That's a big part of why the sample chapter 3 at http://boost-consulting.com/mplbook/ goes on and on about the importance of polymorphism. Getting lambda to work with template arguments other than types would require an exponential number of template specializations, and getting it to work with *all* possible non-type template arguments, even just for one-argument templates, would require an infinite number of template specializations. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Scott Graham