Here's a solution based on std::array :
std::array<char, sizeof("/tmp/file-XXXXXX")> arr{ "/tmp/file-XXXXXX" };
You can reduce the template with a macro:
#define DECLARE_LITERAL_ARRAY(name, str) std::array<char, sizeof(str)> name{ str } DECLARE_LITERAL_ARRAY(arr, "/tmp/file-XXXXXX");
sizeof is evaluated at compile time, so scanning for a continuous line is not required for its length. The resulting array has zero completion, which you probably want anyway.
source share