[PP] Getting the size of a tuple
Hello, I've just started using the preprocessor library, for a fairly simple task. Essentially I have the have a macro called DECLARE_TESTS, which I use like the following DECLARE_TESTS(2, (Test1, Test2) ) which expands into the following void Test1(); void Test2(); suite() { ADDTEST(Test1); ADDTEST(Test2); } Now the problem: it is inconvenient to have to specify the size of the the tuple in the first macro. Is there any way to deduce the size? The macros I'm using are below. Thanks in advance for any help (positive or otherwise) Sam PS Before you suggest using Boost.Test, we have looked at it, and feel that it is not quite what we're looking for, and I don't want to get into that discussion! :-) #define DECLARE_TESTS(test_count, test_list) \ BOOST_PP_LIST_FOR_EACH(UNITTESTS_DECLARE_TEST, _, BOOST_PP_TUPLE_TO_LIST(test_count, test_list)) \ public: \ ClassToTest() \ { \ BOOST_PP_LIST_FOR_EACH(UNITTESTS_ADD_TEST, _, BOOST_PP_TUPLE_TO_LIST(test_count, test_list)) \ } // implementation macros #define UNITTESTS_DECLARE_TEST(R, _, name) void name(); #define UNITTESTS_ADD_TEST(R, _, name) ADDTEST(name)
participants (1)
-
Sam Partington