From: Daniel James (daniel_at_[hidden])
Date: 2004-08-29 10:34:54
Peder Holt wrote:
> What would be very nice (but probably unattainable) was to reduce this
> into an N process. Any suggestions would be most welcome.
I've no idea how to do that, but I know how to get it to work with a
macro like mine. And possibly improve normal use as well (although, I'm
not sure about that).
You can change foo so that as part of it's return type it returns a
value_list containing the encoded types so far, and keeps adding the
encoded types to it. Then each iteration you call foo the same number of
times (this actually makes things worse, but bear with me...) and change
enocode to pick the appropriate value from the value_list.
Now, since foo can add more than one value to the value_list at a time,
this means you can do more encoding per call to foo. So, it might be
possible to reduce the number times you call foo. Also, since foo is
called the same number of times every iteration, you can use my iterator
macro, which means that the number of calls becomes o(nm), where n is
the preset value, and m is the complexity of the type - this can be a
real gain for simple types.
I've tried adapting your version to do this, I've put the code at:
If you look at typeof.hpp and modifiers.hpp you should get a good idea
of what I've done.
It's only tested on Visual C++ v6.0, and I expect it will probably
require some changes to work on more recent versions. It needs to be
cleaned up considerably, it's only really meant as a demonstration of
I haven't really taken advantage of being able to do more encoding per
call, that will probably require another rewrite and might not be
practicle. So for normal use it's currently worse.
But, when using BOOST_TYPEOF_TYPEDEF it does allow you to specify a
higher number of calls to foo without loosing out for simpler types
(since they only iterate a small number of times). It also generates
slightly shorter value_lists, which reduces the number of iterations
required. This could possibly be worthwhile?
If you've still got it, could I have another look at your original
version? I deleted it when I downloaded your new one. It might be
possible to use the techniques you used there for this type of
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk