Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-10-22 15:39:50


I've discussed this with a few of the authors in person, I just
wanted to flesh out the idea and present it to the Boost community
for thought as well.

A perceived shortcoming of Boost.Tuple is that it is limited in size
by the implementation (with a current implementation allowing for up
to 10 tuple members). The only thing that technically leads to this
limitation is the templated constructor for the tuple type, as the
underlying implementation uses a cons<> list which is limitless.
However, there's a property of tuples in other languages that could
be put to good use to remove the limitation on size. When you add a
tuple(2) (my syntax here, this means a tuple of size 2) with another
tuple(2) you get a tuple(4) containing the values from the original
tuples. This concept will allow you to "construct" tuples of larger
sizes then the limit on the constructor:

tuple<> t = make_tuple(1,2,3,4,5,6,7,8,9,10) + make_tuple(11);

Obviously there's some issues with the above example and some design
decisions that would need to be hashed out here, but the concept
seems sound. One of the big things I see not being addressed by this
idea (though maybe the idea could be extended to handle it) is
handling of tiers.

Beyond this, the only drawback to this "solution" is performance of
concatenating tuples instead of directly constructing them. However,
if a tuple must be larger then 10 it seems to me that the performance
is probably not going to be a huge issue.

Bill Kempf


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