From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-04-04 01:32:36
>David Abrahams wrote:
>>It's not what I'm after. I want the standard release to contain
>>debuggable, expanded code for the commonly-used low-repetition cases
>>(without the need for special user configuration), and for higher
>>repetition counts I would like to use the PP lib.
>I guess I failed to explain my suggestion properly :). Here is another try:
> #include "my_library/preprocessor.hpp"
> #if !defined(BOOST_MY_LIBRARY_GENERATOR_MODE)
> # include "my_library/preprocessed/my_header.hpp"
> # define BOOST_MY_LIBRARY_REPETITION_START 5
> # define BOOST_MY_LIBRARY_REPETITION_END 15
> # define BOOST_MY_LIBRARY_REPETITION_START 0
> # define BOOST_MY_LIBRARY_REPETITION_END 5
Hmm... That is an ingenious idea. Let me get this one more time. The
- debuggable code for low repetition cases from 0 to D
- generated code for high repetition cases from D to N
- ability to verify the correctness of both debuggable and generated code
Here is a refinement of the header template:
// Always include macro definition headers.
#include <macro definition headers required>
// Add any code here not generated, including:
// - #includes for normal headers required by the code
// - definitions that are not generated
// Include the nicely formatted debuggable cases.
#define GENERATOR_START D
#define GENERATOR_END N
#define GENERATOR_START 0
#define GENERATOR_END D
// Macros generating code from GENERATOR_START to GENERATOR_END
When the above header is normally included:
- the header includes the debuggable cases from 0 to D from a pregenerated
and formatted header, and
- then generates the cases from D to N using macros.
When the GENERATE macro is defined:
- the header simply generates cases from 0 to D.
In order to generate the debuggable cases, while (re)installing the library,
you do something like this:
cpp -DGENERATE header | cpp_pretty_print > debuggable_cases
No code is actually duplicated. All we now need is the cpp_pretty_print
>P.S. Just in case if you want to try the above, here is
>BOOST_MY_LIBRARY_PP_REPEAT_FROM_TO macro definition:
I think that a variation of this macro (namely with the extra parameter as
it enables composition) might be worth including in the preprocessor
Actually, I think there should be one for each repeat dimension. What do you
Join the worlds largest e-mail service with MSN Hotmail.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk