I want to do the following:
std::unique_ptr buffer = new char[ /* ... */ ] { \"/tmp/file-XXXXXX\" };
Obviously, it doesn\'t work
I don't get why you're not using std::string; you can do str.empty() ? NULL : &str[0] to get a non-const pointer, so the constness of str.c_str() is not going to pose a problem.
std::string
str.empty() ? NULL : &str[0]
str.c_str()
However, note that this is not null-terminated.