Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-07-10 10:03:06


Markus Werle wrote:
> A resolution with which g++ is happy again is:
>
> struct if_
> {
> private:
> enum { value = static_cast<bool>(C::value) };
>
> typedef if_c<
> value
> , T1
> , T2
> > almost_type_;
> etc.
>
> Does this solution have any impact on compilation time?

Most probably. I haven't measured it for this case, but from former
benchmark, I know that *every* type and *every* value counts. Well, I
calculated "Apfelmännchen" at compile-time, so I needed speed :))
Especially types are slow and you are adding an additional unnamed
enum-type in your code above. But there might be another solution,
although not very elegant:

struct if_
{
private:
   typedef if_c<
      bool(C::value)
      , T1
      , T2
> almost_type_;
...

the GCC likes it much better than the static_cast-version and you avoid
a new type. You might want to run some benchmarks for your "typical"
applications, though :)

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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