Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-18 16:37:19


Dear Boost developers,

based on some experiments which I recently made with Typeof and Spirit, Joel de
Guzman asked me if I would like to add "official" Typeof support to Spirit and got
me in touch with Dan Marsden, who recently added experimental Typeof support to
Phoenix2.

Dan and I started discussing how Typeof support could look like for the two
libraries and agreed in one important point: things should be consistent.
Dan pointed out to me that it would be best to use a consistent scheme for adding
Typeof support not only for Spirit and Phoenix2 but for all Boost libraries and
therefore suggested shifting the discussion (previously in private email) to the
Boost developers mailinglist.

There are some suggestion on how such a scheme could look like at the end of this
post.

I'm looking forward to your comments.

Thanks,

Tobias

Suggestions on possible schemes:

( 'a_lib' in the examples denotes a placholder for the name of the library,
'a_component.hpp' denotes the name of a public header of the library. )

1. Create a 'typeof_support' directory reflecting the public headers of the
library. The user enables Typeof support by including additional headers.

Example:

     #include <boost/a_lib/a_component.hpp>
     // ^^^ usual library header
     #include <boost/a_lib/typeof_support/a_component.hpp>
     // ^^^ contains the registration for the header above

2. The Typeof registration is done in one separate header per library (module)
that checks the include guards to register the components, where the registration
is guarded by "registration guards" (as suggested by Arkadiy Vertleyb in the
"Typeof and MPL" thread). The user enables Typeof support for the whole library by
including a single header.

Example:

     #include <boost/a_lib/a_component.hpp>
     #include <boost/a_lib/typeof_support.hpp>
     // The typeof_support header would do the following:
     // - Check the include guard macros to see which files have been
     // included
     // +-- For each of these files: register the components defined within
     // (guarded by a "registration guard macro")
     // - Define a macro to notify library headers #includeD later that the
     // Typeof support header has to be re-#includeD
     // (for large libraries this approach can be applied on a per-module basis)

3. The Typeof registration is put into the library's headers protected by some
conditional. The user enables (or disables) Typeof support by defining a macro.

Example:

     #define BOOST_A_LIB_TYPEOF_SUPPORT
     // ^^^ (or even do it in the Jamfile)
     #include <boost/a_lib/a_component.hpp>


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