Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-01-09 05:03:56


Rob Caldecott ha escrito:

> 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?

Try

  BOOST_CHECK_EQUAL((func<std::string, int>("Test" , 1234)), 1234);

HTH,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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