|
Boost : |
From: Asger Alstrup Nielsen (alstrup_at_[hidden])
Date: 2002-03-29 16:53:36
Gary, your quoting is difficult to parse for me. Could you consider to
use a more standard way of quoting?
> Asger>>------------------------
> Problem 3: Implement concat, which joins a container of
> containers into a single container.
> <<-----------------------------
>
> template<typename L>
> typename L::value_type
> concat(L const & l1, L const & l2) {
> typename L::value_type result;
>
> // just nest the loops.
> for_each(l1.begin(), l2.end(),
> ll::transform( (&_1)->*begin(),
> (&_1)->*end(),
> back_inserter(result),
> _1)
> );
> return result;
> }
>
> /note: since we can't overload operator.(), we use operator&
> to allow us to use Operator ->* instead of bind. (which also works.)
While I understand the code above, I just re-read the documentation for
operator->* a few times. It is still greek to me. I didn't know there
was a operator->* in C++ at all, so that is probably why. Maybe you
could help poor souls like me, and explain this a bit more?
In particular, I think it would be helpful to state the relation with
bind, and symmetrically, in the bind section, reference the operator->*.
> Like any good programmer/carpenter/plumber, we expect you to use the
> right tool for the job. With LL you just get some more tools.
I understand that. I am trying to find out how and what I can use this
new tool for. So far, there is still much to learn, and beyond the
obvious examples, it is hard for me to find out how to use the tool to
improve my code without trying.
The point of the exercise was to investigate to what extend LL allows
you to do more functional programming in C++. A part of this is to use
functions as lego bricks, and compose these to build new functions. So
far, this has been unsuccesful due to the stated problems.
In other words, I have discovered that for me the tool is not quite
ready to do that yet.
In addition, like any good programmer/carpenter/plumber, I try to find
out how the tools can be improved. I expect the tool provider to have
the same interest as far as it is practical.
Greets,
Asger Alstrup Nielsen
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk