小编Ayu*_*rma的帖子

c++ - 如何在c ++中打印许多带有名称及其对应值的变量?

#include <bits/stdc++.h>
using namespace std;

#define __deb(X...) (cout << "[" << #X << "]:" << X)
template <typename... type>
void debug(type &&... args)
{
    ((__deb(args)), ...);
}

int main()
{
    int a = 1, b = 3;
    debug(a,b);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到了像 [args]:1[args]:3 这样的输出,但我想要像 [a]:1[b]:3 这样的输出

c++ templates variadic-templates

3
推荐指数
1
解决办法
164
查看次数

标签 统计

c++ ×1

templates ×1

variadic-templates ×1