|
Boost Users : |
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2007-01-09 14:24:22
On 1/9/07, Rob Caldecott <robert.caldecott_at_[hidden]> 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
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