Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-08-29 09:37:33


"Daniel James" <daniel_at_[hidden]> wrote
> I've come up with an alternative way to invoke the typeof emulations
> that have been posted. It basically works by defining an iterator over
> the encoded type. Unfortunately, it can't be used inside a function, and
> is awkward to use in general, but has the advantage is that it only has
> to define the call to foo once, which might result in faster compile
times.

I believe (and please correct me if I am wrong) that what you actually mean
is the call to foo need to be defined as many times as actually needed as
opposed to always BOOST_MPL_LIMIT_VECTOR_SIZE times in my implementation. I
don't see how you can get away with defining call to foo just "once" 'cause
you still need to do it for every "pos".

Being able to call foo exactly as many times as actually needed would be
very attractive, but I think, any attempt to implement this (including
yours) would suffer from the same problem: new templates need to be created
at the time typeof us used. This results from unability to pass expression
into a template, so templates have to be re-created on the call site for any
given expression by the means of preprocessor.

This introduces the problem of naming such classes. You employ __LINE__ to
solve it, but I don't believe it's enough, since problems can easily pop up
when envoking typeof from different files.

So I still better like the approach where TYPEOF macro expands to a single
call to a template meta-function, with no need to automatically create
intermediate classes. This way it can be used in any context, and we don't
introduce additional issues related to automatic class generation at the
call site.

Regards,
Arkadiy


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