Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-10-29 12:30:24


AMDG

Douglas Gregor <dgregor <at> osl.iu.edu> writes:

> There are several libraries that have this kind of problem. typeof needs
> registrations, serialization needs serialize() functions, MPI needs
> datatype traits, etc. I wonder if we can solve this problem for all of
> Boost with some kind of automatic scheme that says: if you include
> header A from one library and header B from another library, you
> automatically get whatever glue makes A and B work well together.
>
> It's relatively simple to implement this for two headers. In header A
> you have:
>
> #ifdef HEADER_B_INCLUDED
> # include <glue_a_and_b.hpp>
> #endif
>
> In header B you have:
>
> #ifdef HEADER_A_INCLUDED
> # include <glue_a_and_b.hpp>
> #endif
>
> For the general case, we would probably want a "glue" subdirectory whose
> directory mimics the Boost directory structure (like a generalized
> version of your typeof_registrations suggestion). Each header in "glue"
> would have a bunch of #ifdef's checking all of the various other
> library/header names and including the appropriate glue code.
>
> Overall, it's O(N^2) work in the number of data
> structures/headers/libraries (depending on how we chop it up), but users
> would get all of the important glue "for free".
>
> - Doug
>

The work needs to be done anyway! This is just a convenient
way to package it.

There should probably be some way to automate the process.
For example every library that need this feature could
have a directory nested directory called auto_include.
Then the header boost/typeof/detail/auto_include/ref.hpp e.g.
should contain a comment looking like:

    // boostauto_include: boost/typeof/typeof.hpp boost/ref.hpp

This will cause two things to happen:
a) The file boost/auto_include/boost/typeof/typeof.hpp
   will be generated and will look like

  #ifndef BOOST_AUTO_INCLUDE_BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
    #define BOOST_AUTO_INCLUDE_BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
  #endif

  #ifdef BOOST_AUTO_INCLUDE_BOOST_REF_HPP_INCLUDED
    #include <boost/typeof/detail/auto_include/ref.hpp>
  #endif

  // more stuff involving typeof

  Similarly, boost/auto_include/boost/ref.hpp will be updated.

b) The headers boost/ref.hpp and boost/typeof/typeof.hpp will
   be checked to verify that they contain
   #include <boost/auto_include/boost/ref.hpp> and
   #include <boost/auto_include/boost/typeof/typeof.hpp>
   respectively. It's probably not a good idea to automatically
   update these files.

I'm willing to write the necessary script if this
seems like a good way to go.

In Christ,
Steven Watanabe


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