Boost logo

Boost :

From: Mat Marcus (mmarcus_at_[hidden])
Date: 2001-12-13 15:37:37


MPL includes macros such as BOOST_MPL_MAKE_F_X(MyMFQuoted, MyMF). As an
implementation detail, this macro wraps a metafunction, MyMF, inside of a
struct, MyMFQuoted. In a recent post I found it convenient label this
wrapping process "Quoting" after common lisp's #'. If one pursues this
analogy than it might make sense to change the name of 'apply' to 'eval' for
symmetry. If we also change the macro name to BOOST_MPL_QUOTE_F_X then here
is one before/after scenario:

// BEFORE

template <class T>
struct MyMF {
        typedef /*...*/ type;
};

BOOST_MPL_MAKE_F_X(MyMFQuoted, MyMF);

template <class TList, class QuotedMF>
struct AnAlgorithm {
        /* ... */
        typedef typename
          QuotedMF::template apply<TList>::type temp;
};

//AFTER

template <class T>
struct MyMF {
        typedef /*...*/ type;
};

BOOST_MPL_QUOTE_F_X(MyMFQuoted, MyMF);

template <class TList, class QuotedMF>
struct AnAlgorithm {
        /* ... */
        typedef typename
          QuotedMF::template eval<TList>::type temp;
        /* ... */
};

Another alternative would be to use the MetaFunctor/call concept (aka
function class):

template <class T>
struct MyMF {
        typedef /*...*/ type;
};

BOOST_MPL_METAFUNCTOR_F_X(MyMetaFunctor, MyMetaFunction);

template <class TList, class MetaFunctor>
struct AnAlgorithm {
        /* ... */
        typedef typename
          QuotedMF::template call<TList>::type temp; // call?
        /* ... */
};

In any case it seems to me that apply is somewhat ambiguous. Thoughts?

- Mat


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk