Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-04-11 20:25:49


Joel de Guzman wrote:
> > The above implementation is useless for 'tiny_list' (and any type
sequence
> > we use here at work).
>
> This emphasizes my point. Writing an algorithm in MPL is not as
> straightforward. It relies on intimate knowledge of some basic
> infrastructure to do well. On the other hand, STL relies almost
> solely on "first principles only".

MPL relies on "first principles only" as well. One of them is spelled "Use
iterators to decouple the algorithms from particular sequence
representation". Sounds familiar, doesn't it? :)

>
> Now this is is not a bad thing, considering the power MPL gives.
> And considering too that the C++ template metaprocessor was not
> designed as an FP language.
>
> However, extra effort must be provided by the MPL author(s) to make
> writing MPL algorithms as user friendly as possible.

That was one of the goals of the library. Most of custom algorithms (and, in
fact, most of the algorithms MPL offers out-of-box) can be (and are)
implemented in terms of what we call "the basic iteration algorithm" -
'iter_fold_if' (as you've seen it with 'count_if' example). In other words,
in most cases you don't have to deal with manual sequence iteration at all
(unless you want to, of course). You just write the core of the algorithm -
an operation that should be executed on every step through the sequence, and
then pass that operation to [iter_]fold[_if] to do the rest of the job for
you.

> At this point, it seems that the interface to the authoring of MPL
> algorithms is tied to its implementation.

I am not quite sure that do you mean by that (but it's certainly not true
:). Could you clarify, please?

Aleksey


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