[Effective-cpp] Item Assignments for Effective STl
Terje Slettebø
tslettebo at chello.no
Tue Jun 17 07:05:41 EDT 2003
>From: "Tarjei Knapstad" <tarjeik at chemcon.no>
> On Mon, 2003-06-16 at 18:08, Terje Slettebø wrote:
> >
> > I got bitten by it again, yesterday, so I have a thing or two to say
about
> > it... :)
>
> On a related note I usually get "bitten" by forgetting to add extra
> parens when using templates with multiple arguments in macro calls :)
>
> MY_MACRO(MyTemplateFunc<int, float>(someObj));
Ah, yes. The really "fun" part is when you can't add parentheses, such as
when passing a type... :)
One way around that is to make a typedef, and pass that, instead.
Another is to some scaffolding, like:
#define IDENTITY1(a) a
#define IDENTITY2(a,b) a,b
#define IDENTITY3(a,b,c) a,b,c
(Yes, it looks corny but it works; trust me. :) )
template<class,class>
struct test {};
IDENTITY2(test<char,int>) value; // Ok, now
Regards,
Terje
More information about the Effective-cpp
mailing list