Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2005-05-22 05:21:51


"David Abrahams" <dave_at_[hidden]> wrote

> >> Okay, how about the one enclosed here, then?
> >
> > Now you have both size() and size_<> instantiated LIMIT_SIZE times ;-)
>
> According to Eric, you need something like size_<> to workaround vc++
> bugs, though.

Not if the expression is simplified. It's really multiple calls to sizeof
what drives the compiler crazy.

> Okay, let me try one more. I think this one gets close
> to the minimal number of instantiations required to work around VC++
> bugs.

Still, select<> is instantiated LIMIT_SIZE times...

The beauty of the ugly solution with the conditional operator is that it
brings the algorithm complexity, in terms of template instantiations, to
O(m), where m is the real size of the vector. True, we pay by doubling the
amount of template lookups, and expression evaluations, but it looks like it
pays.

It's a pity that VC8 chokes on this in some contexts -- maybe we'll be able
to get MS to fix it before the real thing comes out. Until then, I believe
we should specialcase the VC8, and I think your first suggestion, with no
separate size function will do the job fine.

We could even limit this to dependent contexts, since I don't think this
problem exists outside templates. However your other suggestion, that
allows to remove _TPL, makes this impossible. Still, I love the idea of
removing _TPL so much that I am willing to pay this price...

Regards,
Arkadiy


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