Boost logo

Boost :

From: Sohail Somani (s.somani_at_[hidden])
Date: 2007-01-20 20:39:57

Hi all,

A miniature project this week was started by me this week (I was bored?) to determine the minimum arity of a bind expression. On Peter's and Joel's suggestion, I made the changes non-intrusive: i.e. the listN's used to hold the argument sequence are fusion forward sequences. Currently there is no runtime component and I suspect there will need to be some generated "at" specializations, but I don't expect this to be too difficult. So anyway two-point-one questions:

1) How do I get the type of a bind expression as a metafunction (or something) so that I can have a metafunction (or something) to return the min_arity of a bind expression?
2) How do I make a patch that includes my added files? cvs diff only shows diffs to existing files
2.1) With 2) can someone help me make the fusion sequence a mpl sequence? I can't seem to get this to work properly



PS: I'm a bit shaky on the whole metafunction concept as my attempts to get the mpl book were thwarted, hence the "or something" :) Go easy on me!

(Below is the current implementation of min_arity)

// TODO: make this into some sort of metafunction - or something
// probably will have to always have a function to deduce the bind
// expression type but the rest of it can probably be moved
template<int MinArity,typename BindExpression>
void min_arity(BindExpression const &)
    // should be a meta function of some sort
    typedef typename placeholders<BindExpression>::placeholders_list

    // a list of... argument positions
    typedef typename result_of::transform<
>::type arg_positions;

    // the maximum element
    typedef typename mpl::max_element<
        arg_positions>::type iter;

    // if there are no placeholders
    typedef typename result_of::empty<arg_positions>::type no_placeholders;

    // can only dereference iterator if there were placeholders => atleast one argument position
    typedef typename mpl::eval_if<
>::type min_arity_type;

    BOOST_MPL_ASSERT(( boost::is_same<min_arity_type,mpl::int_<MinArity> >));

    int a=9;

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