Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-05-22 08:15:51


"Arkadiy Vertleyb" <vertleyb_at_[hidden]> writes:

> "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...

Yes, but not LIMIT_SIZE * N, where N is the number of different types
passed to BOOST_TYPEOF. So it's a one-time cost, which is better than
what I posted earlier.

> 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.

OK.

> 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.

Yes, I have got one of their engineers working on it :)

> 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.

I think my latest is better.

> 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...

Agreed.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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