Passing a template which requires a comma to a single-argument macro

后端 未结 4 2162
自闭症患者
自闭症患者 2021-01-03 00:02

I have some code that essentially condenses down to

#define FOO(a)
FOO(std::map);

But it emits a compile error (too many ac

4条回答
  •  情歌与酒
    2021-01-03 00:12

    The preprocessor will only treat unparenthesised commas as a macro argument separator. So what you can do is rewrite std::map into something that has parentheses around it. A simple one might be decltype(std::map()).

提交回复
热议问题