В ответе здесь (Как использовать псевдоним «constexpr and runtime» ) — хороший вариант его использования.
РЕДАКТИРОВАТЬ:
Моя идея заключалась в том, чтобы вместо написания чего-то вроде:
Код: Выделить всё
#include
int foo() {
return strlen("text");
}
Код: Выделить всё
#include
// template_strlen() would be a function that gets the length of a compile-time const string via templates
#define STRLEN(a) (__builtin_constant_p(a) ? template_strlen(a) : strlen(a))
int foo() {
return STRLEN("text");
}
Все, что мне для этого нужно, это вариант __builtin_constant_p() .
Подробнее здесь: https://stackoverflow.com/questions/209 ... r-visual-c