Is it possible to have a function argument which is __builtin_constant_p?
This macro works fine:
#define FOO(a) {\
static_assert(__builtin_constant_p(a));\
}
void bar() {
FOO("abc");
}
I would like to turn FOO
into a function. However, this doesn't work:
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");
}
How can I change the argument of foo
to make it work? Possibly using templates / std::forward or something similar?
Aucun commentaire:
Enregistrer un commentaire