Boost logo

Boost :

Subject: [boost] Single letter template type causes errors in compile of program_options and filesystem boost libraries
From: Mike Collier (mcollier69_at_[hidden])
Date: 2008-12-18 12:54:43


Hi,

Problem lIbraries: program_options and filesystems
Version: Release 1.37.0
System: Mac OS X 10.5.6, Red Hat Linux Enterprise 4, Red Hat Linux
Enterprise 3
Compiler : gcc 4.0 and gcc 3.3

I have just started trying to use the boost libraries. I tried
starting with program options and filesystem.
Unfortunately both of these do not compile in my environment because
of the use of single letter variable and template types.

For example in alignment_of.hpp the template:

template <unsigned A, unsigned S>
struct alignment_logic
{
    BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
};

causes error and in operators.hpp the template:

// Import a 3-type-argument operator template into boost (if
necessary) and
// provide a specialization of 'is_chained_base<>' for it.
# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
  BOOST_IMPORT_TEMPLATE3(template_name3) \
  template<class T, class U, class V, class B> \
  struct is_chained_base< ::boost::template_name3<T, U, V, B> > { \
    typedef ::boost::detail::true_t value; \
  };

causes errors.

The errors are the result of using single letters for variables or
template types. The reason for the errors is in my compile environment
( electrical engineering related ) defines are used for the
convenience of writing units in code. These defines exist in a vendor
supplied header in my project:

#define A
#define V
#define W
#define s
#define S
#define J

among many others to denote units ( in these defines the units are
Amps, Volts, Watts, Seconds, and Joules ).

These defines come from the vendor of the software I am using and
can't be easily changed. I believe the correct change is to use longer
names for variables and template types in the boost library headers,
which means changing the boost library headers. I can do this locally
in my copy of the headers, but it seems to me a better design is to
use longer names in the boost libraries in first place. I don't see
any benefit to using the single letter names in the boost library
headers.

Does anyone have other solutions to this problem or know of reasons
why single letter variable and template type names are used in the
boost libraries?

Thanks,
Mike


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