Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-06-25 21:48:01


"Douglas Gregor" <gregod_at_[hidden]> wrote in message
news:200206252151.21098.gregod_at_cs.rpi.edu...
> I haven't done any speed tests yet (but will at some point), although I do
> know that it is a common compiler optimization in OO languages to replace
> virtual function calls with switch-on-type constructs when the set of
> possible types is bounded at compile time. I can't possibly fathom how it
> would be less efficient to branch to a known location based on an integer
> comparison than to call an arbitrary memory location.

Ah, I'm guilty of a little misunderstanding. I believe that adding
switch-on-type to Variant is possible and might be very attractive
efficiency-wise.

> Programming with function objects and STL algorithms often requires more
lines
> of code than the equivalent explicitly coded for-loop, but I don't see any
> objections to that. MPL does the same thing at the metaprogramming level,
> where metafunctions are factored out and supplied to generic algorithms.
> What's the difference? [This is rapidly becoming off-topic. We should
> probably take it into a separate MPL thread.]

STL does reduce the amount of code you write quite drastically, and it would
be hard to convince me otherwise because I know that from direct and
extensive experience. But why compare mpl with stl instead of concretely
discussing on mpl as it stands. Because to me it looks like variant.hpp, as
a sample usage of mpl, is not quite a compelling argument in mpl's favor.
I'm not sure, but it might be the case that variant's code would benefit in
terms of length, simplicity, understandability, and compilation times, if it
would be written without mpl.

Andrei


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