Boost logo

Boost :

Subject: Re: [boost] [mpl] is there a or_seq like logical metafunction?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-02-12 17:19:24


On 02/12/09 12:20, Steven Watanabe wrote:
> AMDG
>
> Larry Evans wrote:
>> In the vault, under "Template Metaprogramming", there's a profile,
>> in and_seq_profile.zip, of the find_if method and the while_ method
>> for implementing and_seq. The while_ method shows 100 fewer
>> instantiations for a 3 element vector of nullary logical metafunctions.
>
> I'm not seeing any such drastic differences. Even for 10 values,
> the difference is just under 70 template instantiations on msvc.
> and about 50 on gcc.

That's curious!

I guess the compiler can do some sort of analysis to figure
which templates really need to be instantiated and which don't.
Maybe when instantiating some template, the compiler looks
at which other templates are needed by the methods in that
template (wait, there were not methods in while_, but maybe in
the IfOps arg to while_) and then instantiates only those,
but other compilers don't bother with that and instantiate
templates even though they're not used.

Steven, do you have any idea why there's a difference?
I was using gcc-4.2 on ubuntu. Also, maybe the g++ on
windows implements the templates differently than on linux.

>
> Also, for comparing performance, it's probably better to rely on
> measuring compilation time. Not all templates take the same
> amount of time to instantiate.
>

One reason I was interested in the instantiation profiler instead
of compile times is that I'd reand elsewhere that timing benchmarks
were not that meaningful. I thought number of instantiations would
be more meaningful. Guess I was wrong :(


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