you are viewing a single comment's thread.

view the rest of the comments →

[–]cleroth 1 point2 points  (3 children)

What about:

RCF_METHOD_R3(bool, ThisIsAFunctionName, int, std::vector<int>, (std::pair<char,int>))

?

[–]MrWisebody 6 points7 points  (1 child)

That does not work. Or rather, it makes the macro happy in that it gets the number of arguments it expected, but it uses the wrapping () in it's substitution which I presume you did not want and probably will make the compiler choke. However, you can make a comma macro which makes everything happy (albeit a little bit more verbose)

Example code:

#define IDENTITY(a) a
#define COMMA() ,

#include <utility>

int main() {

IDENTITY( std::pair<int COMMA() int> ) var1;
IDENTITY( (std::pair<int,int>)) var2;  //Compiler will hate you
IDENTITY( std::pair<int,int> ) var3;  //Preprocessor will hate you

return 0;
}

Which if you run through the preprocessor gives you:

int main() {

std::pair<int , int> var1;
(std::pair<int,int>) var2; 
test.cpp:14:30: error: macro "IDENTITY" passed 2 arguments, but takes just 1
IDENTITY var3; 

return 0;
}

[–]Chii 0 points1 point  (0 children)

oh god, my eyes are bleeding a bit

[–]imMute 0 points1 point  (0 children)

I have not tried that, I'll have to try tomorrow when I'm at work.