|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2006-11-04 05:11:20
Aleksey,
Many thanks for your detailed reply. I think the second scenario with
pre-generated headers convinces me more, since our compilation times are not
optimal at all :(. But as you stated in the book: more work for compiler
means less work at runtime. These were not exactly the words, but I can
remember the meaning.
I have one more question: I tried to use the preprocess_map.py script, but
encounter some problems. Running it on Windows with Python 2.5 causes the
following output:
D:\projects\libraries\boost_1_33_0\libs\mpl\preprocessed>preprocess_map.py
Usage:
preprocess_map.py <mode> <boost_root> [<source_file>]
Purpose:
updates preprocessed version(s) of the header(s) in
"boost\mpl\map\aux_\preprocessed" directory
Example:
the following command will re-generate and update all 'apply.hpp'
headers:
preprocess_map.py all f:\cvs\boost apply.cpp
How do I submit here the max map size? Or did you mean that I should write a
similar script, which pregenerates headers by my own?
If I look inside of this script, there is one call to main which passes 3
parameters, but probably this does not work. If I pass parameters as in this
example, I get an error that gcc is not installed. Ok, I will install it and
put it into my PATH env var, but still the question, how do specify the size
of max map?
Is there any way to include pre-generated headers for 150 elements into the
next boost release? Probably the unnumbered mpl::map template could go until
50 types to save compilation time, but if someone wishes to go above, he/she
could use numbered map templates like map150. The problem, why I am going to
suggest it, is that if someone pre-generates the header and updates the
version, it is possibly, that pre-generated headers will be removed and
project maintainer (not usually programmer who generated these headers) will
suddenly get compiler errors and will have to repeat this procedure again.
And some other question:
Dave said, that mpl::map had some bug fixes from the 1.33 release to
upcoming 1.34. Will these preprocessing scripts break the changes?
Many thanks for your effort and time,
Ovanes
-----Original Message-----
From: Aleksey Gurtovoy [mailto:agurtovoy_at_[hidden]]
Sent: Saturday, November 04, 2006 3:29 AM
To: boost-users_at_[hidden]
Cc: Ovanes Markarian; dave_at_[hidden]
Subject: Re: [mpl::map] generating map for 150 types
Hi Ovanes,
> I need to define a map with int_<1...150>->Type1...150 pairs.
>
> Im source file I define:
>
> #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
> #define BOOST_MPL_LIMIT_MAP_SIZE 150
>
> #include <boost/mpl/map.hpp>
A word of caution: redefining BOOST_MPL_LIMIT_MAP_SIZE is not recommended.
Doing so globally will make you pay for what you probably don't use (unless
all present and future 'map' usages in your project demand the 150-elements
limit), and doing so within a translation unit will lead to an ODR
violation.
If you need to construct a sequence beyond the default size, use its
numbered form
(http://www.boost.org/libs/mpl/doc/refmanual/variadic-sequence.html).
> When compiling I get an error in the file:
> ...\boost\include\boost-1_33_1\boost\mpl\map.hpp on line: 36 fatal
> error C1083: Cannot open include file: 'boost/mpl/map/map150.hpp':
> No such file or directory
>
> Development environment is Visual C++ 8 Express Edition
>
> The help states:
[...]
What the BOOST_MPL_LIMIT_MAP_SIZE docs don't say is that there is a default
upper limit of 50 elements for the macro's value:
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_MAP_SIZE 50
#include <boost/mpl/map.hpp> // compiles
This upper limit is overridable as well, but since touching
BOOST_MPL_LIMIT_MAP_SIZE is not recommended anyway, I'll instead demonstrate
how to bump the number of map's numbered forms up to 150.
The simpliest way would be just this:
#include <boost/mpl/map/map50.hpp>
#include <boost/preprocessor/iterate.hpp>
namespace boost { namespace mpl {
# define BOOST_PP_ITERATION_PARAMS_1 \
(3,(51, 150, <boost/mpl/map/aux_/numbered.hpp>))
# include BOOST_PP_ITERATE()
}}
// use map150<....>
with the caveat that the extra 100 map templates are generated on the fly
using the preprocessor, which isn't ideal from the compilation time
standpoint.
Alternatively, you can pre-generate these extra templates once and for all
using the '$BOOST_ROOT/libs/mpl/preprocessed/preprocess_map.py'
script and the existing numbered map files in the
'$BOOST_ROOT/boost/mpl/map/' and '$BOOST_ROOT/libs/mpl/preprocessed/map/'
subdirectories as an example.
HTH,
-- Aleksey Gurtovoy MetaCommunications Engineering
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net