
Arkadiy Vertleyb wrote:
OK, but this means we have to change the syntax of REGISTER macros to do something like:
#include BOOST_TYPEOF_REGISTER_...(...)
I remember you suggested this during the review. I am still not quite comfortable with the idea...
No it's a different pair of shoes I'm talking about here (in fact, having used the library some more I found several situations that require REGISTER_* to be macros, so you can safely forget about my review suggestion). What I'm talking about here is purely an implementation issue and doesn't affect the interface at all (typeof/vector.hpp). I'll attach a patch that highlights the changes needed to make things work for 118 <= LIMIT_SIZE <= 238.
Here's my modifications:
^^^^^ BTW excuse my beautiful english... ;-)
How much faster is it?
Hard to say in general. It depends on the case: bjam run in ${BOOST}/libs/typeof/test ============================================= without preprocessed files: about 2.5 minutes with preprocessed files: about 1.5 minutes original version: about 2.5 minutes * * slightly slower than the 1st Now to the cases that hurt: Test with LIMIT_SIZE = 117 ========================== without preprocessed files: 45 seconds with preprocessed files: 13 seconds original version: 52 seconds Test with LIMIT_SIZE = 238 ========================== without preprocessed files: about 5.5 minutes with preprocessed files: about 0.5 minutes original version: <limit exceeded> Test with LIMIT_SIZE = 250 ========================== without preprocessed files: <limit exceeded> with preprocessed files: about 0.5 minutes original version: <limit exceeded> More benchmarks needed? Just download the archive and copy the contents of the folder therein to ${BOOST}/boost/typeof. Setting the macro BOOST_TYPEOF_PREPROCESSING_MODE enforces preprocessing, otherwise preprocessed files are used. Boost.Typeof rocks... Cheers, Tobias Index: boost/typeof/vector.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/typeof/vector.hpp,v retrieving revision 1.2 diff -u -r1.2 vector.hpp --- boost/typeof/vector.hpp 9 Dec 2005 03:55:38 -0000 1.2 +++ boost/typeof/vector.hpp 6 Jan 2006 20:41:51 -0000 @@ -12,7 +12,9 @@ #include <boost/preprocessor/repeat_from_to.hpp> #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/inc.hpp> +#include <boost/preprocessor/dec.hpp> #include <boost/preprocessor/comma_if.hpp> +#include <boost/preprocessor/iteration/local.hpp> #ifndef BOOST_TYPEOF_LIMIT_SIZE # define BOOST_TYPEOF_LIMIT_SIZE 50 @@ -20,7 +22,7 @@ // iterator -#define BOOST_TYPEOF_spec_iter(z, n, _)\ +#define BOOST_TYPEOF_spec_iter(n)\ template<class V>\ struct v_iter<V, mpl::int_<n> >\ {\ @@ -31,7 +33,9 @@ namespace boost { namespace type_of { template<class V, class Pos> struct v_iter; // not defined - BOOST_PP_REPEAT(BOOST_TYPEOF_LIMIT_SIZE, BOOST_TYPEOF_spec_iter, ~) + #define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_iter + #define BOOST_PP_LOCAL_LIMITS (0,BOOST_PP_DEC(BOOST_TYPEOF_LIMIT_SIZE)) + #include BOOST_PP_LOCAL_ITERATE() }} #undef BOOST_TYPEOF_spec_iter @@ -44,7 +48,7 @@ #define BOOST_TYPEOF_typedef_fake_item(z, n, _)\ typedef mpl::int_<1> item ## n; -#define BOOST_TYPEOF_define_vector(z, n, _)\ +#define BOOST_TYPEOF_define_vector(n)\ template<BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_COMMA_IF(n) class T = void>\ struct vector ## n\ {\ @@ -55,7 +59,10 @@ namespace boost { namespace type_of { - BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_TYPEOF_LIMIT_SIZE), BOOST_TYPEOF_define_vector, ~) + #define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_define_vector + #define BOOST_PP_LOCAL_LIMITS (0,BOOST_TYPEOF_LIMIT_SIZE) + #include BOOST_PP_LOCAL_ITERATE() + }} #undef BOOST_TYPEOF_typedef_item @@ -64,7 +71,7 @@ // push_back -#define BOOST_TYPEOF_spec_push_back(z, n, _)\ +#define BOOST_TYPEOF_spec_push_back(n)\ template<BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_COMMA_IF(n) class T>\ struct push_back<BOOST_PP_CAT(boost::type_of::vector, n)<BOOST_PP_ENUM_PARAMS(n, P)>, T>\ {\ @@ -76,7 +83,9 @@ namespace boost { namespace type_of { template<class V, class T> struct push_back; // not defined - BOOST_PP_REPEAT(BOOST_TYPEOF_LIMIT_SIZE, BOOST_TYPEOF_spec_push_back, ~) + #define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_push_back + #define BOOST_PP_LOCAL_LIMITS (0,BOOST_PP_DEC(BOOST_TYPEOF_LIMIT_SIZE)) + #include BOOST_PP_LOCAL_ITERATE() }} #undef BOOST_TYPEOF_spec_push_back