# define functionPattern(type)
void return##type(){
cout << #type << endl;
}
and, yes, it’s legal. return##type concatenates “return” and the replacement text for “type” into a single token. And #type is simply the replacement text for “type” surrounded by quotes. So, for example:
functionPattern(foo)
would expand to
void returnfoo(){
cout << "foo" << endl;
}
i.e.:
##type, just replace the text for “type” into a single token. #type, repace the text for “type” into “type” (surrounded by quotes).