Boost logo

Boost :

From: Thomas Becker (tmbecker1_at_[hidden])
Date: 2003-03-26 16:12:22


> On 26 Mar 2003, Anthony Williams wrote:
> > It strikes me that if you dereference n iterators,
> you have n values, and the
> most natural way to store them is a tuple.

--- Douglas Paul Gregor <gregod_at_[hidden]> wrote:
> I would agree if tuples and argument passing were
> more closely linked,
> i.e., if passing a tuple to a function meant that
> the tuple would be
> automagically unpacked into separate arguments.

>From a user's point of view, this seems a very strong
argument to me. For instance, in my software, I use
combining iterators with functionals such as
std::divides. If I were forced to accept my arguments
as a tuple, I couldn't use any of these functionals
without the extra unpacking step. Besides, introducing
the tuple in the middle between dereferencing the
iterators introduces the possibility of inadvertent
extra value copies. Another big headache for the user.
And why all that? I really don't see any advantage to
this intermediate step of packaging the derefernced
iterators into a tuple, only to unpack it in 99.999%
of the cases. What for?

Once again: The big picture is that we want an
iterator that parallel-iterates over several sequences
and upon dereferencing, applies some processing to the
dereferenced iterator. This processing is specified by
the user via a fuctional. One of the many, many things
that such a functional can do is package the arguments
into a tuple, if that is what's needed. (Although we
still haven't seen a single real-life request for
that). Why on earth would I, in the general case,
introduce a packaging/unpackaging step in the middle
between dereferencing the iterators and passing them
to the functional? Am I missing something?

BTW, Anthony: In one of my CUJ columns, I made a big
fool of myself by gratuitously packaging function
arguments into a tuple, and I seem to remember that
you were one of the people who pointed this out to me.
Looks like we switched sides in this argument... ;-)

Thomas Becker
Zephyr Associates, Inc.
Zephyr Cove, NV

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com


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