Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-08-31 13:53:39


"Daniel James" <daniel_at_[hidden]> wrote

> Still, his implementation is fantastic, considering that it runs on
> Visual C++ 6. Since my last post, I've made quite a lot of progress at
> getting my variation to cope with complicated expressions with less
> calls to 'foo'. But Peder's version takes about half the time to run my
> tests, and will scale a lot better.

Besides...

I've just made a little improvement to my implementation:

I added another function to determine the size of encoded expression:

template<class T>
char(&size(const T&))[
mpl::size<typename encode_type<mpl::vector0<>, T>::type>::value
];

Then I modified the nth item extraction to look like this:

#define BOOST_TYPEOF_TYPEITEM(z, n, expr)\
boost::mpl::int_<sizeof(boost::type_of::foo<(n <
sizeof(boost::type_of::size(expr)))?n:sizeof(boost::type_of::size(expr))>(ex
pr))>

Note that now no new templates gets instantiated for n larger than size.

I tried it at work, and this improvement cuts almost in half the compile
time of my example (with Spirit, Lambda, etc.), presumably having taken care
of smaller types.

I'll post the modified system later, when I am done with integral template
parameters.

Regards,
Arkadiy


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