
Hi, I'm using Boost.Preprocessor to create specializations of a class I have named InputSource. in the iteration loop, I have the following: # define i BOOST_PP_ITERATION() # define INPUT_repeat(z, n, user) user template<typename t_return, BOOST_PP_ENUM_PARAMS(i, typename t_param)> class InputSource< t_return, BOOST_PP_ENUM_PARAMS(i, t_param) BOOST_PP_COMMA_IF( BOOST_PP_AND(BOOST_PP_NOT_EQUAL(i, 0), BOOST_PP_NOT_EQUAL(i, MAX_PARAMETERS)) ) BOOST_PP_ENUM(BOOST_PP_SUB(MAX_PARAMETERS, i), INPUT_repeat, detail::no_param) > The part that isn't working is the BOOST_PP_COMMA_IF line. When I look at the preprocessor output generated by MSVC9, I get this: template<typename t_return, typename t_param0> class InputSource< t_return, t_param0 BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_BITAND_BOOST_PP_BOOL_BOOST_PP_NOT_EQUAL(1, 0)BOOST_PP_BOOL_BOOST_PP_NOT_EQUAL(1, 5)(BOOST_PP_COMMA, BOOST_PP_EMPTY)() detail::no_param , detail::no_param , detail::no_param , detail::no_param > My iteration limits has been defined as follows: # ifndef MAX_PARAMETERS # define MAX_PARAMETERS 5 # endif # define BOOST_PP_ITERATION_LIMITS (1, MAX_PARAMETERS) I would have expected the preprocessor to show a comma or a blank line, but instead it looks like some macros were not expanded. Any solutions to this problem?

For those interested in the entire file (Somewhat large), here you go: #ifndef BOOST_PP_IS_ITERATING # ifndef vfx_input_InputSource_hpp__ # define vfx_input_InputSource_hpp__ # include <boost/preprocessor/iterate.hpp> # include <boost/preprocessor/repetition.hpp> # include <boost/preprocessor/logical.hpp> # include <boost/preprocessor/punctuation.hpp> # include <boost/function.hpp> # include <boost/signals.hpp> # include <vfx/input/include/detail/no_param.hpp> # ifndef MAX_PARAMETERS # define MAX_PARAMETERS 5 # endif namespace vfx { namespace input { template<typename t_return, BOOST_PP_ENUM_PARAMS(MAX_PARAMETERS, typename t_param)> class InputSource; }} // end namespace vfx::input # define BOOST_PP_ITERATION_LIMITS (1, MAX_PARAMETERS) # define BOOST_PP_FILENAME_1 "InputSource.hpp" # include BOOST_PP_ITERATE() # endif // vfx_input_InputSource_hpp__ #else # define i BOOST_PP_ITERATION() # define INPUT_repeat(z, n, user) user namespace vfx { namespace input { template<typename t_return, BOOST_PP_ENUM_PARAMS(i, typename t_param)> class InputSource< t_return, BOOST_PP_ENUM_PARAMS( i, t_param ) BOOST_PP_COMMA_IF( BOOST_PP_AND(BOOST_PP_NOT_EQUAL(i, 0), BOOST_PP_NOT_EQUAL(i, MAX_PARAMETERS)) ) BOOST_PP_ENUM( BOOST_PP_SUB(MAX_PARAMETERS, i), INPUT_repeat, detail::no_param ) > { private: typedef typename boost::function<t_return (BOOST_PP_ENUM_PARAMS(i, t_param))> FunctionType; typedef typename boost::signal<t_return (BOOST_PP_ENUM_PARAMS(i, t_param))> SignalType; SignalType m_observers; public: void Publish( BOOST_PP_ENUM_BINARY_PARAMS(i, const t_param, ¶m) ) { m_observers(BOOST_PP_ENUM_PARAMS(i, param)); } void Subscribe( FunctionType slot ) { m_observers.connect( slot ); } }; }} // end namespace vfx::input # undef i #endif // BOOST_PP_IS_ITERATING

Problem solved: I was missing a couple of boost/processor includes, so the macros couldn't be found and thus could not be expanded. This resulted in no compiler errors, which scares me. I'm also able to pass in an insufficient number of template parameters into my class and it also compiles just fine.
participants (1)
-
Robert Dailey