Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2002-01-17 08:44:23


Vladimir Prus wrote:
> Again, I'd like to see numbers. After bcc has converted
>
> tuple<int, int> t(1, 2)
>
> in 40 assembly instructions, I don't believe much in optimization
> capabilities of compilers.

Yet it is entirely possible to implement the tuple facilities in the way
that the above statement will give you the same assembly code as
"std::pair<int, int> p(1, 2)" - instruction to instruction. Before you ask
how :), here is my answer - using PREPROCESSOR library. In some sense, such
implementation could even be simpler (no template magic, but preprocessor
one instead ;), and more flexible, in sense that you could configure the
maximum size of a tuple "container" by simple #define, e.g. #define
BOOST_TUPLE_SIZE 15. Of course, the approach also has it's drawbacks -
debugging/compile-time errors localization difficulties is the major one,
but they are solvable as well.

In fact, some times ago Roland Richter has posted here an announcement of
something that, I think, is very close to what I have in mind (I haven't
look at the code) - see http://groups.yahoo.com/group/boost/message/21094.
But it looks like nobody is interested in "tuple<int, int> t(1, 2)" that
generates 4 instead of 40 assembly instructions ;). Is it so?

(Sorry Roland, I _did_ plan to respond, - I have done a very similar thing
with mpl::type_vector<>, - but got buried in other things...)

Aleksey


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