I want to do the following:
std::unique_ptr buffer = new char[ /* ... */ ] { \"/tmp/file-XXXXXX\" };
Obviously, it doesn\'t work
Since you requested a dynamic array and not wanting to count the length, that rules out std::array
. What you're asking for is really just std::string
- it's dynamic (if need be), and initializes just fine from a char*
without counting the length. Internally, it stores the string in a flat array, so you can use it as such, via the c_str()
call.