Can a constexpr c-string used as template parameter be instantiated in a template function?
问题 I have been prototyping a library in which I would like to use a c-string value defined locally in a function as a non-type template parameter. In essence, the bare minimum implementation is the following (see on godbolt): #include <cstdio> #include <type_traits> template <char const* C> class compile_string {}; template <typename T> auto foo() { static constexpr char const CSTR[] = "Hello, World!"; return compile_string<CSTR>{}; } int main() { auto shorty = foo<short>(); auto inty = foo<int>