On 1/9/07, Rob Caldecott <robert.caldecott@gmail.com> wrote:
I am trying to test a template function that takes two template parameters, and, because of the "comma in macros" compiler issue, I have hit a brick wall. For example:
template<typename T1, typename T2> int func(const T1& t1, const T2& t2) { ... }
BOOST_CHECK_EQUAL(func<std::string, int>("Test", 1234), 1234);
When compiling BOOST_CHECK_EQUAL above, I get an error due to the comma between std::string and int. As this is a function, I cannot use typedef, and trying to #define a workaround also fails (I am using VS2005).
Any ideas how I can test template functions with more than one template parameter?
Thanks in advance.
Hi, Rob - try this (i.e. brackets around the function call - should make the preprocessor ignore the commas in the template parameter list and the function parameter list) BOOST_CHECK_EQUAL((func<std::string, int>("Test", 1234)), 1234); Stuart Dootson