Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-02-13 08:10:24


Dave Gomboc wrote:
>
> > Ah, that's the reason. But given my recent discomfort about
> > unmaintainable code, look at it again:
> >
> > # if BOOST_WORKAROUND(__HP_aCC, <= 33900)
> > template<bool cond, typename T> struct enable_if;
> > # else
> > template<bool, typename T> struct enable_if;
> > # endif
> >
> > Does this really makes sense? Shouldn't we just keep one version with
> > names for template parameters? AFAICS this should work for all compilers
> > and it could be a general boost coding guideline to always provide names
> > for template parameters. Comments?
>
> Nah, the vendors will never fix problems that we hide. In some regular
> code I might just switch it, but since some vendors _are_ using Boost to
> test their compiler conformance, we should leave the HP workaround in (and
> use the same or a new workaround for VisualAge also). That way, when they
> compile with BOOST_NO_CONFIG they will see the problem.

It's a reasonable approach. Another one might be a macro called
BOOST_UNUSED_TEMPLATE_PARAMETER which will be used like
BOOST_STATIC_CONSTANT and resolves to nothing for conforming compilers
and leaves a dummy name in for broken compilers. Usage:

template< BOOST_UNUSED_TEMPLATE_PARAMETER( bool, cond ),
          BOOST_UNUSED_TEMPLATE_PARAMETER( typename, T ) > struct
enable_if;

Note that I do not prefer this style, I just want to mention another
option. I think it's still better than #ifdef's but I won't bother too
much if there is one coding guideline which could solve all issues.
Boost is already too complicated to add political/educational stuff for
compiler vendors instead of adding just the technically needed stuff for
compilers.

<irony>

We could continue by adding BOOST_FOR to replace all for-loops in case a
compiler has broken scope for declared
variables. For conforming compilers:

#define BOOST_FOR for

and for broken compilers:

#define BOOST_FOR if(false);else for

there are so many ways to obfuscate the code... hehe...

</irony>

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