Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-27 08:10:48


----- Original Message -----
From: Douglas Gregor <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, September 27, 2001 12:14 AM
Subject: Re: [boost] tuple's 'ignore' question

> On Wednesday 26 September 2001 01:45, you wrote:
> > Here comes a 'user' post:
> >
> > I've recently started to use the tuple library to change some old code
in
> > one of my projects.
> > Tuples are used by some headers that at some point must be precompiled
> > (otherwise compilation time will be prohibiting);
> > but with Borland 5.5.1 the header 'tuple_basic.hpp' cannot be included
in a
> > precompiled header due to the static global variable 'ignore'.
> >
> > Is there any workaround?
>
> "ignore" could be marked extern instead of static, then defined elsewhere.
> Now that Boost has a build system it might be logical to have a macro
> BOOST_CONSTANT_OBJECT_DECL(declaration)
>
> that will be either:
> namespace {
> declaration;
> }
>
> -or-
> extern declaration;
>
> The former will be used if only Boost headers are being used, whereas the
> latter will be used if the Boost libraries are compiled and contain the
> definitions for these objects.
>
Unfortunately, ignore is already using form one:
Here is a transcript of the (original) code:

  // "ignore" allows tuple positions to be ignored when using "tie".
  namespace {
   detail::tuples::swallow_assign ignore;
  }

Only a explicit 'extern' keyword would solve the problem, but then I would
have to define the variable somewhere else. Not a good thing to do.

> > The thing I HAD to do in order to go on was to change 'ignore' from a
> > global variable into a free function, but of course this changes the
> > semantics.
>
> Only the type of ignore matters, so you really won't be changing semantics
at
> all; just the syntax.
>
Good point.
However, and I don't like to change the syntax on my own, so I would like to
see a solution (this or another one) accepted by boost and included as a
fix.

> > BTW: In which namespace is 'ignore' supposed to go? I'm confused... (or
> > Borland is confused because it puts ignore in boost)
>
> It should be in an anonymous namespace inside boost::tuples. That way one
> "copy" exists per translation unit, so we don't have to deal with being
> careful to define it in only one translation unit.
>
"boost::tuples" was what I expected, but it is in "boost" (without 'tuples')
But that's fine!!!
I just got confused because in the review version I was familiar with
everything went into boost::tuples, but in this release, it is in 'boost'.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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