Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-01-31 11:38:52


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uvfmsyz69.fsf_at_boost-consulting.com...
> "Andy Little" <andy_at_[hidden]> writes:
>
> > Hi,
> > Following preliminary ok of "pow" mpl metafunction by Alexey
> > Gurtovoy... Here are some basic headers for mpl functions pow_, root_
and
> > reciprocal.
> >
> > useage:
> > boost::mpl::pow_<type,exponent>::type
> > boost::mpl::root_<type,exponent>::type
> > boost::mpl::reciprocal<type>::type
>
> These aren't very interesting metafunctions, since they're all
> equivalent to mpl::always<implementation_defined> ;-)

Oops sorry perhaps read 'undefined',' user defined' not implementation
defined :-)
Not to stay that way just havent had time to write some simple examples.
(pow_<int_,int_> should be easy!) Could use one of my own but doesnt mean
much to many -->

The problem is I have specialised plus, minus, multiplies etc. for use in
'expression templates'. (think is right term).
However it would be odd to put these in separate namespace. OTOH I could
derive all from mpl in other namespace, but I didnt want to be 'ad-hoc'. ;-)
But maybe that is how mpl functions should be used?. Was waiting for the
book ... :-)

    template<
        typename Coherent_exponent ,
        typename Incoherent_mux,
        typename Tag
        typename Exponent
>
    struct pow_<
                pqs::q_unit<
                    Coherent_exponent,
                    Incoherent_mux,
                    Tag
>,
                Exponent
>{ // incoherent and tags removed
        // multiply exponents
        typedef typename pqs::q_unit<
            typename multiplies<
                Coherent_exponent,
                Exponent
>::type,
            typename Incoherent_mux::zero_type,
            typename Tag::default_type
>::type type;
    };

>
> What is the reason for the trailing underscores?

In case of pow_ to stop it name-clashing with pow(x,y), if 'using
boost::mpl' ,using std. In case of root_ for similarity with pow.
In case of reciprocal the underscore is very small. Thought 'power' might
also clash with other names.
But any suggestions appreciated.

regards
Andy Little


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