小编Blu*_*bie的帖子

如何为std :: cout创建一个可变宏?

我如何创建一个带有可变数量参数的宏,并使用std :: cout打印出来?很抱歉,如果这是一个菜鸟问题,在搜索答案后找不到任何澄清可变参数的宏.

概念示例:

#include <iostream>
#define LOG(...) std::cout << ... << ... << std::endl
int main() {
    LOG("example","output","filler","text");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

exampleoutputfillertext
Run Code Online (Sandbox Code Playgroud)

c++ c-preprocessor c++11

11
推荐指数
2
解决办法
6791
查看次数

标签 统计

c++ ×1

c++11 ×1

c-preprocessor ×1