Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-19 06:09:22


Arkadiy Vertleyb wrote:
> "Tobias Schwinger" <tschwinger_at_[hidden]> wrote
>
>>
>>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
>
>
> This scheme looks similar to what we've done with std headers. It may make
> sense for typeof_support/a_component.hpp to include a_component.hpp.
>
>
>>2. The Typeof registration is done in one separate header per library (module)
>>that checks the include guards to register the components,
>
>
> Thus avoiding the nead to forward-declare everything?
>

Well this need could be avoided in case 1) as well by making the typeof header
include the library header it reflects...

>
>>where the registration
>>is guarded by "registration guards" (as suggested by Arkadiy Vertleyb
>>in the "Typeof and MPL" thread).
>
>
> It was first suggested by David Abrahams, and was meant to synchronize
> registrations of the same library done by different library users. What you
> are suggesting sounds like a new idea to me, and I am not sure I completely
> understand this. Can you ellaborate?
>

The library would implement typeof support like this:

--- boost/<LIB>/typeof_support.hpp

     #if !defined(<LIB>_TYPEOF_SUPPORT)
     # define <LIB>_TYPEOF_SUPPORT
     #endif

     #if defined(<include guard macro 1st file>)
     # if !defined(<typeof guard macro 1st file>)
     # define <typeof guard macro 1st file>
     // <-- register components in file 1 here
     # endif
     #endif

     #if defined(<include guard macro 2nd file>)
     # if !defined(<typeof guard macro 2nd file>)
     # define <typeof guard macro 2nd file>
     // <-- register components in file 2 here
     # endif
     #endif

     // [...]

--- at the end of every source file:

     #if defined(<LIB>_TYPEOF_SUPPORT)
     # include <boost/<LIB>/typeof_support.hpp>
     #endif

This technique could be applied:
- in combination with 1) to allow maximum convenience
- or per-module bases having a global typeof_support header for the
   library that includes the typeof_support headers for its modules.

>
>>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)
>

Hope it helps.

Regards,

Tobias


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