1
我有这个简单的(无用)代码来说明这个问题:C++宏和模板,多个参数错误
template<typename _Tx, typename _Ty>
struct foo{};
#define TO_STRING(Type) #Type
int main()
{
std::string sInt = TO_STRING(int);
std::string sfoo1 = TO_STRING(foo<int, float>); //warning and unexpected value - "foo<int"
std::string sfoo2 = TO_STRING((foo<int, float>)); //no warning, still unexpected value "(foo<int, float>)"
}
有没有办法通过使用多个参数的宏模板,而无需使用 ()
?
不,没有办法。 – 2013-04-10 12:35:38
你用什么编译它,所以当你将1或2个参数传递给宏时它会默默吞下? – 2013-04-10 12:37:51
@RomanSaveljev Visual Studio 2010 – Felics 2013-04-10 12:39:21