是否有可能是__builtin_constant_p的函数参数?
此宏可以正常工作:
#define FOO(a) {\
static_assert(__builtin_constant_p(a));\
}
void bar() {
FOO("abc");
}
我想将FOO
变成一个函数。但是,这不起作用:
void foo(const char* a) { // how to change argument to make this work?
static_assert(__builtin_constant_p(a)); // Fails with: Static_assert failed due to requirement '__builtin_constant_p(a)
}
void bar() {
foo("abc");
}
如何更改foo
的自变量以使其起作用?可能使用模板/ std :: forward或类似的东西吗?